Getting an error when trying to setup Exchange Online ForwardingAddress in Azure Runbook

Nick 0 Reputation points
2024-05-30T12:31:55.16+00:00

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,256 questions
Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
547 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,582 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.