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!
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,368 questions
Exchange | Exchange Server | Development
587 questions
Windows for business | Windows Server | User experience | PowerShell
Sign in to answer