Get-MgServicePrincipalSynchronizationJob fails with Status: Unauthorized for Application based Authentication.

Michael Hoffman 20 Reputation points
2023-01-13T17:18:01.64+00:00

I am trying to create an automation using application permissions to get synchronization job status and am getting the following error "Get-MgServicePrincipalSynchronizationJob_Get: The server responded with a Request Error, Status: Unauthorized"

Debug output shows app only and scopes correctly.

DEBUG: [CmdletBeginProcessing]: - Get-MgServicePrincipalSynchronizationJob begin processing with parameterSet 'Get'.

DEBUG: [Authentication]: - AuthType: 'AppOnly', AuthProviderType: 'ClientCredentialProvider', ContextScope: 'Process', AppName: '****'.

DEBUG: [Authentication]: - Scopes: [Application.ReadWrite.OwnedBy, Application.ReadWrite.All, Directory.ReadWrite.All].

Any suggestions would be appreciated.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
584 questions
No comments
{count} votes

Accepted answer
  1. Andy David - MVP 109.8K Reputation points Microsoft MVP
    2023-01-13T18:09:10.3+00:00

    Assign the Application to the "Hybrid Identity Administrator" Azure role as well.


0 additional answers

Sort by: Most helpful