With organizational security needs, regularly managing app role assignments for service principals is crucial. The Remove-MgServicePrincipalAppRoleAssignment cmdlet enables administrators to revoke delegated app permissions from service principals, ensuring permissions align with current requirements and reducing lateral movement risk.
This article shows you how to remove service principal app role assignments using both the Microsoft Entra admin center and Microsoft Graph PowerShell:
The Entra admin center provides a graphical interface where you can visualize and remove assignments:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "AppRoleAssignment.ReadWrite.All"
Run the script below by providing the target service principal and app role assignment IDs
Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "sp-id" -AppRoleAssignmentId "assignment-id"
Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "sp-id" -AppRoleAssignmentId "assignment-id" -Confirm
Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "sp-id" -AppRoleAssignmentId "assignment-id" -WhatIf
The following essential parameters can be used along with the Remove-MgServicePrincipalAppRoleAssignment cmdlet:
| Parameter | Description |
|---|---|
| -ServicePrincipalId | The object ID of the service principal (required). |
| -AppRoleAssignmentId | The app role assignment ID to remove (required). |
| -WhatIf | Simulates the action without executing it. |
| -Confirm | Prompts before removal. |
| -Headers | Send custom HTTP headers. |
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: