none
can't get the value of publicdelegatesbl in a variable RRS feed

  • Question

  • Hello,

    When a mailbox is disabled if the user was as a delegate in another mailbox and that the user didn't remove him from his delegate, he'll see a unknown SID in his delegate. In order to prevent this I would like to run a script that will remove delegatebl of that the user who would be disabled.

    Servers are on Exchange 2007 SP3 RU6. No powershell V2 is installed... only V1. That's my main problem. I have the Quest cmdlet installed. I can only used them.

    I wrote a script but my problem right now is only to get the value publicdelegatebl in a variable... I have a blank return...

    $QADUser = (Get-QADUser "$User" -IncludedProperties publicdelegates,publicdelegatesbl).publicDelegatesbl
    Write-Host $QADUser
    Any help please?


    • Edited by Nolwen Thursday, February 27, 2014 8:31 AM
    Thursday, February 27, 2014 8:31 AM

Answers

  • This works:

    get-mailbox | foreach {
     $dn = $_.distinguishedname
     $m = [ADSI]"LDAP://$dn"
     $d =  $m.properties.publicDelegates
     $bl = $m.properties.publicDelegatesBL
     # do something with $d and $bl
    }
    Remember, though, that simply removing the delegate from the publicDelegates property will not remove the special rule in the mailbox that might be doing things like sending a copy of a meeting request to a mailbox that's no longer present in your organization. You have to clean up that mess using Outlook. So use a script to identify the problem and Outlook to remove the delegate from the mailbox.


    --- Rich Matheisen MCSE&I, Exchange MVP

    Saturday, March 1, 2014 9:10 PM

All replies

  • This works:

    get-mailbox | foreach {
     $dn = $_.distinguishedname
     $m = [ADSI]"LDAP://$dn"
     $d =  $m.properties.publicDelegates
     $bl = $m.properties.publicDelegatesBL
     # do something with $d and $bl
    }
    Remember, though, that simply removing the delegate from the publicDelegates property will not remove the special rule in the mailbox that might be doing things like sending a copy of a meeting request to a mailbox that's no longer present in your organization. You have to clean up that mess using Outlook. So use a script to identify the problem and Outlook to remove the delegate from the mailbox.


    --- Rich Matheisen MCSE&I, Exchange MVP

    Saturday, March 1, 2014 9:10 PM
  • Thanks it worked... but now when I am trying to remove the publicdelegatesbl I have a constraint violation error. I understand what you've told me about the fact we cannot clean up the message without using outlook. But is there any other solution except Outlook? I meant even with the EWS it's not possible? 

    Currently I have to be able to remove the delegate added by outlook and by scritpt...

    $resFile="C:\Scripts\leavers.txt"
    
    $allLeavers = Get-Content $resFile
    
    ForEach($leaver in $allLeavers) {
        $valeurs = $leaver.split(";")
        $aliasTH = $valeurs[0]
        $smtpTH = $valeurs[1]
        $User = Get-Mailbox | Where-Object { $_.Alias -match $aliasTH -and $_.EmailAddresses.ToStringArray() -match $smtpTH }
        $userCN = $User.DistinguishedName
        $Error.Clear()
    
        $userPath = "LDAP://$userCN"
        $user=[adsi]$userPath
        $publicDelegates = $user.properties.publicDelegates
        $publicDelegatesbl = $user.properties.publicDelegatesbl
        Write-Host "$publicDelegates,$publicDelegatesbl"
        $publicDelegatesbl.Remove("$userCN")
        $user.CommitChanges() 
    }



    • Edited by Nolwen Monday, March 3, 2014 1:57 PM
    Monday, March 3, 2014 7:43 AM
  • You can't make any direct modifications to any "back link" objects. Their value is calculated by the AD. What you want to do (well, what you mustdo) is remove the delegate from the publicDelegates property on the mailbox, not from the mailbox belonging to the delegate.

    For questions about EWS, the first place to look is on Glen Scales blog. For example:

    http://gsexdev.blogspot.com/2012/03/ews-managed-api-and-powershell-how-to.html


    --- Rich Matheisen MCSE&I, Exchange MVP

    Tuesday, March 4, 2014 2:58 AM