1 minute reading time
(237 words)
SOLVED: Azure PowerShell Runbook error "Failed UnAuthorized" (incorrect permissions)
SOLVED: Azure Runbook error "Failed UnAuthorized" when trying to connect to Exchange Online. Fixed by assigning correct permissions for connecting to Exchange Online PowerShell
Problem: Azure PowerShell Runbook error - Failed UnAuthorized
Error when trying to connect to Exchange Online from an Azure Automation Account PowerShell runbook
Failed
UnAuthorized (UnAuthorized)
Solution: Check Azure Service Principal permissions are correct
To connect to Exchange Online from an Azure PowerShell runbook you will need to set the following permissions:
The permissions will need to be assigned to either the Azure AD App registration or System assigned Managed Identity that you are using to connect to Exchange Online
- Exchange ManageAsApp
- Exchange Administrator role
- MS Graph Permissions
See these guides for more detailed instructions:

Connect to Exchange Online using App registration and Certificate from Azure Runbook (Complete Guide) - TechLabs
How to connect to Exchange Online from an Azure Automation Account PowerShell Runbook using an App Registration and self-signed Certificate

Connect to Exchange Online using Azure System Managed Identity (Complete Guide) - TechLabs
How to connect to Exchange Online from an Azure Automation Account PowerShell Runbook using a System assigned Managed Identity
After assigning the correct permissions, the PowerShell runbook runs successfully
Comments