-
Notifications
You must be signed in to change notification settings - Fork 0
Get ExchangeErrorsGraph
Get-ExchangeErrorsGraph.ps1 retrieves users in a tenant that have Exchange Online provisioning errors via the Microsoft Graph beta endpoint. It parses the raw XML error detail stored in the serviceProvisioningErrors property, formats it for readability, and optionally exports the results to JSON for remediation tracking.
- Provisioning Error Detection - Queries all users and filters to those with Exchange provisioning errors
- XML Error Parsing - Extracts human-readable error descriptions from raw XML error payloads
- Full Tenant Scan - Handles OData paging to ensure all users are evaluated
- Formatted Table Output - Displays UPN and error details in a readable console table
-
JSON Export - Exports results to
C:\temp\ExchangeErrors.jsonfor tracking and remediation - Client or Interactive Auth - Supports both app-only and interactive authentication
- PowerShell 5.1 or later
-
Microsoft.Graph(auto-installed if missing) -
MSAL.PS(installed by Get-GraphToken)
-
Get-GraphToken- Token acquisition -
Get-GraphHeaders- Authorization headers
| Permission | Type | Purpose |
|---|---|---|
Directory.Read.All |
Application | Read user provisioning error properties |
Note: Uses the Microsoft Graph beta endpoint (
/beta/users). Properties may change with future API updates.
Type: String
Required: Yes
Description: The Azure AD tenant ID to authenticate against.
Type: String
Required: No
Description: The app registration client ID. Omit to use interactive authentication.
Type: String
Required: No
Description: Client secret for app-only authentication. Omit for interactive flow.
Type: Switch
Required: No
Description: If specified, exports results to C:\temp\ExchangeErrors.json. Creates C:\temp if it doesn't exist.
Get-ExchangeErrorsGraph `
-TenantId "12345678-1234-1234-1234-123456789012" `
-ClientId "abcdefab-1234-1234-1234-abcdefabcdef" `
-ClientSecret "your-secret"Get-ExchangeErrorsGraph `
-TenantId "12345678-1234-1234-1234-123456789012" `
-ClientId "abcdefab-1234-1234-1234-abcdefabcdef" `
-ClientSecret "your-secret" `
-exportGet-ExchangeErrorsGraph `
-TenantId "12345678-1234-1234-1234-123456789012" `
-export# Run with export
Get-ExchangeErrorsGraph -TenantId "<tenant-id>" -ClientId "<client-id>" -ClientSecret "<secret>" -export
# Review the exported JSON
$errors = Get-Content "C:\temp\ExchangeErrors.json" | ConvertFrom-Json
$errors | ForEach-Object {
Write-Host "User: $($_.userPrincipalName)" -ForegroundColor Cyan
Write-Host "Error: $($_.Errors)" -ForegroundColor Red
Write-Host ""
}Found 3 users with provisioning errors.
UserPrincipalName Errors
----------------- ------
john.doe@contoso.com Unable to set this property. The value associated with a linked role...
service.acct@contoso.com The operation failed. Please refer to the error details for more info...
legacy.user@contoso.com The email address "alias@domain.com" is already being used by another...
[
{
"userPrincipalName": "john.doe@contoso.com",
"Errors": "Unable to set this property. The value associated with a linked role..."
}
]Cause:
- Tenant has no Exchange provisioning errors (ideal state!)
- Insufficient permissions to read
serviceProvisioningErrors
Solution: Verify Directory.Read.All permission has admin consent granted:
# Test read access
Connect-MgGraph -Scopes "Directory.Read.All"
Get-MgUser -Top 1 -Property serviceProvisioningErrorsCause: The beta endpoint URL may change with Microsoft updates.
Solution: Verify current beta endpoint and property availability in Microsoft Graph Explorer.
Solution: Verify TenantId, ClientId, and ClientSecret are correct. Ensure the app registration exists and the secret hasn't expired.
Cause: Microsoft occasionally changes the XML schema of serviceProvisioningErrors.errorDetail.
Solution: Inspect the raw property value:
$user = Get-MgUser -UserId "user@domain.com" -Property serviceProvisioningErrors
$user.serviceProvisioningErrors | ConvertTo-Json- Get-GraphToken - Token acquisition
- Get-GraphHeaders - Authorization headers
- v1.0 (2025-06-25) - Initial public release
- Overview
- Start-LyncCsvExporter
- Get-ComprehensiveLyncReport
- Get-LyncHealthReport
- Get-LyncInfrastructureReport
- Get-LyncServiceStatus
- Get-LyncUserRegistrationReport
- Export-ADLyncTeamsMigrationData
- New-Office365Accounts
- Sync-ContactsFromCsv
- Set-EmailToSharedAccount
- Set-SMTPForward
- Invoke-UserSignOutAndBlock
- Security Assessment Scripts (coming soon)
- Azure Automation (documentation pending)
- Get-GraphToken
- Get-GraphHeaders
- Get-AzureResourcePaging
- Get-EnterpriseAppUsage
- Get-ExchangeErrorsGraph
- Get-PBIWorkspaceUsageReport
- Intune Management (documentation pending)