Getting an error when trying to setup Exchange Online ForwardingAddress in Azure Runbook
Nick
0
Reputation points
Hello,
I am trying to setup an Azure Automation Runbook in which I convert a User Mailbox to a Shared Mailbox and setup a ForwardingAddress.
I setup all the permissions and converting the mailbox is working, setting a forwarding address throws the following error:
|Microsoft.Exchange.Data.Directory.InsufficientPermissionsException|Source server:AM0PR08MB4529.eurprd08.prod.outlook.com doesn't have write permission to target DC:. Usually it indicates that target forest isn't an account partition of source forest. The user has insufficient access rights.
This is the script I am using:
Param (
[string] $Employee = ""
)
Connect-ExchangeOnline -ManagedIdentity -Organization <DOMAIN>.onmicrosoft.com
$Mailbox = Get-Mailbox -Identity $Employee -ErrorAction SilentlyContinue
if ($Mailbox -eq $null) {}
elseif ($Mailbox.RecipientTypeDetails -eq "SharedMailbox") {}
else {
Set-Mailbox -Identity $Employee -Type Shared -ErrorAction SilentlyContinue
}
Set-Mailbox -Identity $Employee -DeliverToMailboxAndForward $true -ForwardingAddress "<FORWARDING_ADDRESS>"
If anyone knows a way to solve this please let me know.
Thank you!
Sign in to answer