# Remove user from  Send onBehalf Security group


# Works !

$Owner = Read-Host “Type in valid email address or alias of the owner’s mailbox”
 $User = Read-Host “Type in valid email address or alias of the user whose SEND-ON-BEHALF rights you want to remove”
 
$OwnerMailbox = Get-Mailbox $Owner
 $UserMailbox = Get-Mailbox $User
 $OwnerMailbox.GrantSendOnBehalfTo.Remove($UserMailbox.Identity)
 Set-Mailbox $Owner -GrantSendOnBehalfTo $OwnerMailbox.GrantSendOnBehalfTo

# Dont work!

$Owner = Read-Host “Type in valid email address or alias of the owner’s mailbox”
 $User = Read-Host “Type in valid email address or alias of the user whose SEND-ON-BEHALF rights you want to remove”
 $OwnerMailbox = Get-Mailbox $Owner
 $UserMailbox = Get-Mailbox $User
 $OwnerMailbox.GrantSendOnBehalfTo -= $UserMailbox.DistinguishedName
 Set-Mailbox $Owner -GrantSendOnBehalfTo $OwnerMailbox.GrantSendOnBehalfTo