Announcement

Collapse
No announcement yet.

[PS]Removing SendOnBehalf rights

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [PS]Removing SendOnBehalf rights

    Hi all,

    I'm building an application to get things done in Exchange 2010.
    This application builds the PowerShell code and then executes it on a remote Exchange server. This has been working perfectly, until now.

    When removing SendOnBehalf (SOB) rights, I get the magnificent error:
    Method invocation failed because [System.Collections.ArrayList] doesn't contain a method named 'op_Subtraction'.


    The PScode executed is:
    Code:
    	
    $DeleteUser = *mailbox*,*mailbox2*,*mailbox3*,etc
    $a = (get-mailbox "[email protected]").GrantSendOnBehalfTo
    ForEach ($SingleUser in $DeleteUser)
      {
           $a -= (get-mailbox $SingleUser).Identity
       }
    set-mailbox "[email protected]" -GrantSendOnBehalfTo $a
    The strange part is; when I execute the code manually in Powershell, it succeeds with no error at all, all accounts nicely removed from the SOB-list.

    For your info: Granting users SOB-rights through this application works flawlessly.

    My questions:
    • What am I doing wrong?
    • Is there a workaround to remove SOB-rights?


    UPDATE:
    I've also tried to replace
    Code:
     $a -= (get-mailbox $SingleUser).Identity
    
    with
    
     $a -= *userDN*
    but that doesn't help..

    Many thanks in advance!
    Last edited by chravtacque; 13th December 2011, 22:15.
Working...
X