The Get-MgServicePrincipalOauth2PermissionGrant cmdlet retrieves all OAuth2 delegated permission grants that have been assigned to a service principal in Microsoft Entra ID (formerly Azure AD). By running this cmdlet, admins can identify which permissions have been consented to, who consented to them, and whether the consent was granted tenant-wide or user level. This is beneficial for security reviews, compliance audits, and troubleshooting, as excessive or misconfigured permissions could introduce risks.
This article shows you how to view OAuth2 permission grants using both the Microsoft Entra admin center and Microsoft Graph PowerShell:
OAuth2 grants can be reviewed under each enterprise application's Permissions section.
Install Microsoft Graph module and connect with app role assignment read scope:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "AppRoleAssignment.Read.All"
Run the command below with the service principal ID:
Get-MgServicePrincipalOauth2PermissionGrant -ServicePrincipalId <sp-id>
Get-MgServicePrincipalOauth2PermissionGrant -ServicePrincipalId "abcdef12-3456-7890-abcd-ef1234567890"
Get-MgServicePrincipalOauth2PermissionGrant -ServicePrincipalId "abcdef12-3456-7890-abcd-ef1234567890" -Filter "resourceId eq 'resource-guid'"
Get-MgServicePrincipalOauth2PermissionGrant -ServicePrincipalId "abcdef12-3456-7890-abcd-ef1234567890" -Top 5
The following are some essential parameters that can be used along with the Get-MgServicePrincipalOauth2PermissionGrant cmdlet:
| Parameter | Description |
|---|---|
| -ServicePrincipalId | The object ID of the service principal whose grants to retrieve. |
| -Filter | An OData filter expression to refine returned grants. |
| -Top | Limits the number of grants returned. |
| -All | Retrieves all results by paging. |
| -Property | Selects properties to include in the results. |
ADManager Plus, an identity governance and administration solution with comprehensive Microsoft Entra ID management and reporting capabilities, simplifies complex admin tasks from a single, user-friendly console: