The Remove-MgOauth2PermissionGrant cmdlet allows admins to revoke OAuth2 permission grants from applications and service principals in Microsoft Entra ID (Azure AD). These grants define the delegated permissions that a client application has to access resources on behalf of a signed-in user. By removing unnecessary or outdated permission grants, admins can reduce the attack surface, enforce least-privilege access, and maintain tighter security over application-to-resource interactions. This cmdlet is especially useful when decommissioning applications, revoking risky permissions, or cleaning up unused authorizations.
This article shows you how to remove OAuth2 permission grants using both the Microsoft Entra admin center and Microsoft Graph PowerShell:
The Entra admin center provides a graphical interface to remove OAuth2 permission grants associated with applications:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All"
Run the script below the grant’s unique object ID to revoke it from the tenant:
Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId
Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654"
Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654" -Confirm
Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654" -WhatIf
The following are some essential parameters that can be used along with the Remove-MgOauth2PermissionGrant cmdlet:
| Parameter | Description |
|---|---|
| -Oauth2PermissionGrantId | The unique object ID of the OAuth2 permission grant to remove (required). |
| -WhatIf | Shows what would happen without performing the removal. |
| -Confirm | Prompts for confirmation before execution. |
| -Headers | Allows sending custom HTTP headers with the request. |
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: