Getting an error in a runbook.

Tristan MacDonald 0 Reputation points
2024-04-30T17:12:23.7733333+00:00

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
Microsoft Exchange Online
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,796 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,140 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,404 questions
{count} votes