Revoke OAuth2 Permission Grants | Microsoft Graph PowerShell
 
 
 

How to remove OAuth2 permission grants using Microsoft Graph PowerShell

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:

  • M365 admin center
  • PowerShell
 

Remove OAuth2 permission grants using Microsoft Entra admin center

The Entra admin center provides a graphical interface to remove OAuth2 permission grants associated with applications:

  1. Go to Microsoft Entra admin center.
  2. Navigate to Entra ID > Enterprise applications.
  3. Select your desired application.
  4. Go to Permissions (or Permissions and consent )
  5. Find the OAuth2 permission grant to remove, select it, and click Remove and Revoke

Remove OAuth2 permission grants using Microsoft Graph PowerShell

Prerequisites

  • You need the AppRoleAssignment.ReadWrite.All permission or an equivalent privileged role in Microsoft Entra ID.
  • Install and connect to Microsoft Graph PowerShell by running the script below:
    Install-Module Microsoft.Graph -Scope CurrentUser Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All"

Using the Remove-MgOauth2PermissionGrant cmdlet

Run the script below the grant’s unique object ID to revoke it from the tenant:

Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId

Examples

Example 1: Remove a specific OAuth2 permission grant

Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654"

Example 2: Remove a grant with confirmation

Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654" -Confirm

Example 3: Test removal with WhatIf

Remove-MgOauth2PermissionGrant -Oauth2PermissionGrantId "abcdef12-1234-5678-9000-abcdef987654" -WhatIf

Supported parameters

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.

Limitations of using native tools to Remove OAuth2 permission grants

  • PowerShell commands can get complex with different use cases and scenarios.
  • IT admins can spend a lot of time troubleshooting errors, which negatively impacts productivity.
  • Delegation can get tricky since technicians require elevated permissions.

How ADManager Plus helps you manage Microsoft Entra ID

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:

Perform script-free Microsoft Entra ID management and reporting with ADManager Plus

The one-stop solution to Active Directory Management and Reporting
Email Download Link Email the ADManager Plus download link