Removing directory role assignments is essential for enforcing least privilege in Microsoft Entra ID. The Remove-MgRoleManagementDirectoryRoleAssignment cmdlet allows administrators to revoke custom or built-in role assignments from users, service principals, or groups, helping organizations maintain tighter access controls, support compliance requirements, and minimize insider risk by occasionally auditing and cleaning up unnecessary access.
This article shows you how to remove directory role assignments using both the Microsoft Entra admin center and Microsoft Graph PowerShell:
Microsoft Entra admin center provides a graphical method for role removal:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory"
Run the script below by adding the assigment's unique ID:
Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId "assignment-id"
Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId "assignment-id" -Confirm
Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId "assignment-id" -WhatIf
The following essential parameters can be used along with the Remove-MgRoleManagementDirectoryRoleAssignment cmdlet:
| Parameter | Description |
|---|---|
| -UnifiedRoleAssignmentId | The unique ID of the role assignment to remove (required). |
| -WhatIf | Shows what would happen if the cmdlet runs but doesn’t execute it. |
| -Confirm | Prompts for confirmation before removing assignment. |
| -Headers | Allows sending 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: