Getting an error in a runbook.
Hi there,
I've created a runbook to handle offboarding users in office 365. I'm connecting to the graph API, and exchangeonline module. My runbook is working flawlessly except for one specific line which is giving me an error when ran in the runbook (I don't get this error when ran directly from powershell.)
The system managed identity has Exchange.ManageAsApp, Exchange administrator permissions, as well as all valid graph permissions for commands I've called.
Error message:
Set-Mailbox: |Microsoft.Exchange.Data.Directory.InsufficientPermissionsException|Source server:*** 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.
The line in question:
# Disable shared mailbox from showing in GAL
Set-Mailbox -Identity $userEmail -HiddenFromAddressListsEnabled $true