Ever had to set send on behalf rights on a shared mailbox and you just can't seem to find the option in the Exchange control panel?
Well, the option isn't there!
The only way to set these rights is by using powershell. Whether you are using on-premise or online, the same command works!
The easiest way to add the rights is by using this:
Set-Mailbox $mailbox -GrantSendOnBehalfto $user
But beware! If you use it like that and you need to add more users in the future, the previous setting will get overwritten!
For example if you added User 1 today and tomorrow you add User 2. The send on behalf rights for User 1 will be gone but there for User 2.
This is simply fixed by using the following command:
Get-Mailbox -Identity $mailbox -resultsize unlimited | set-mailbox -GrantSendOnBehalfto @{Add="$email"}
This way you get the current settings of the mailbox and pipe it to Set-Mailbox to append the send on behalf rights instead of overwriting it.
I wrote a Powershell script leveraging these commands, I had to use these commands alot and I got tired of typing this over and over.
You can find it here: https://github.com/MoebiusZero/Scripts/blob/main/Powershell/SendonBehalfRights.ps1
I wrote this with Exchange Online in mind because this is what the company I work for is using at the time of writing. But you can modify it yourself to use the Exchange Management Shell without much issue.
The script is a bit more complex than just the few lines above. It does the following:
- It checks the Exchange Online module is installed, if yes continue, if no install it
- It asks you for the mailbox that needs send on behalf rights applied to
- It asks you if you need to give a single or multiple users those rights
- Depending on your choice it will run a single line or loop through the list of users you provided
- It then disconnects the session
Feel free to download the script and modify it to your own needs.