Adding To Existing Send-On-Behalf Lists - and other Multi-Valued Fields
Folks,
This is information for other users - I already have the solution. I've been working on a script that creates shared mailboxes for my company, and when I was granting send-on-behalf permissions to more than one user, only the last user retained the
permission. I did the required searching, and found the forum threads saying this was a multi-valued field and that only the last submission was retained. This got me thinking, and for my issue, I came up with the following PowerShell code for
solution:
$SavSndBhlf = (Get-Mailbox $NewMbx -DomainController $DomCtrl).GrantSendOnBehalfTo
$SendBehalf | % {
$SavSndBhlf.Add($(Get-Mailbox $_.Alias).Identity)
}
Set-Mailbox $NewMbx -GrantSendOnBehalfTo $SavSndBhlf -DomainController $DomCtrl
" These rights are currently granted to ..."
Get-Mailbox $NewMbx -DomainController $DomCtrl | % {
$_.GrantSendOnBehalfTo
} | Ft Name -HideTableHeaders
In this, $NewMbx is the new mailbox I just created, and $SendBehalf is a list of mailboxes that I am granting send-on-behalf permissions. I include the domain controller so I won't need to worry about AD replciation in the rest of my script.
In this script, I first get the current list of accounts or groups with Send-On-Behalf permissions (which on a new mailbox is empty, but this allows me to reuse this same code for updating the same information on existing mailboxes). Next, I add the
new accounts to that list. Then I place the last back on the new mailbox with the Set-Mailbox command.
All in all, it worked out fine for me. This same logic can be used for updating any multi-valued field that won't accept new values to the list - such as Distribution Group membership. HTH ...
Will Martin
June 29th, 2012 8:25am
You don't need to do all of that. See this article:
http://technet.microsoft.com/en-us/library/bb684908
Multivalue property syntax
Action
Syntax
Add one or more values to a multivalued property
@{Add="<value1>", "<value2>", "<value3>"}
Remove one or more values from a multivalued property
@{Remove="<value1>", "<value2>", "<value3>"}
Mike Crowley | MVP
My Blog --
Planet Technologies
Free Windows Admin Tool Kit Click here and download it now
June 29th, 2012 11:11am
Hi Guys,
Thanks for sharing.
Regards,
Simon
July 1st, 2012 10:18pm
Mike,
Thanks for the update! This simplifies my script above to the following:
$SendBehalf | % {
Set-Mailbox $NewMbx -GrantSendOnBehalfTo @{Add=$_} -DomainController $DomCtrl
}
" These rights are currently granted to ..."
Get-Mailbox $NewMbx -DomainController $DomCtrl | % { $_.GrantSendOnBehalfTo } | Ft Name -HideTableHeaders
And you can do much the same thing for removing permissions from a list of accounts.
Will Martin
Free Windows Admin Tool Kit Click here and download it now
July 6th, 2012 7:47am
You weren't asking a question, but instead offering help, so I changed the thread to a comment. If you'd like to change it back, click "change type".
Mike Crowley | MVP
My Blog --
Planet Technologies
July 6th, 2012 8:38am
True, but the thread was still submitted as a question.
Free Windows Admin Tool Kit Click here and download it now
July 6th, 2012 12:45pm
As I said, you're welcome to change it back.
What is your question?
Mike Crowley | MVP
My Blog --
Planet Technologies
July 6th, 2012 3:33pm
I see - you had changed it. I have now marked it as a question, and I marked the responses I felt were the answers people would want to see. THanks, Mike
Free Windows Admin Tool Kit Click here and download it now
July 9th, 2012 1:48pm