Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitWhen managing Microsoft Entra ID (formerly Azure AD), one of the most important administrative tasks is keeping track of who has which roles — especially at the directory level. Whether you’re running audits, reviewing access controls, or troubleshooting permissions, knowing how to retrieve these role assignments is crucial.
This blog will walk you through how to use the Get-MgRoleManagementDirectoryRoleAssignment cmdlet in Microsoft Graph PowerShell to retrieve and understand Azure AD directory role assignments in a clear and straightforward way.
Get-MgRoleManagementDirectoryRoleAssignment is a Microsoft Graph PowerShell cmdlet that allows you to retrieve all role assignments made at the directory scope in Microsoft Entra ID.
Each assignment links:
This cmdlet helps answer questions like:
Here’s why this cmdlet is a must-have in your admin toolkit:
If you're aiming for least-privilege access, periodic reviews using this cmdlet are a best practice.
Get-MgRoleManagementDirectoryRoleAssignment
To get a specific role assignment by ID:
Get-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId "<Assignment-ID>"
Get-MgRoleManagementDirectoryRoleAssignment |
Select-Object Id, RoleDefinitionId, PrincipalId, DirectoryScopeId
This command fetches all role assignments across the tenant. You can use RoleDefinitionId to find the role name and PrincipalId to identify the assigned user or group.
Get-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId "lAPpYvVpN0KRkAEhdxReECvy-ge2vZRIgYix4HUDS_4-1"
Useful when you're tracking a specific assignment from an audit log or need to verify a known role assignment.
You can retrieve it using:
Get-MgRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId ""
Try resolving the ID with:
Get-MgUser -UserId "<PrincipalId>"
Or if it’s a group:
Get-MgGroup -GroupId "<PrincipalId>"
Currently, the cmdlet doesn't support -Filter directly. Instead, fetch all and filter using PowerShell:
Get-MgRoleManagementDirectoryRoleAssignment |
Where-Object { $_.PrincipalId -eq "" }
Here are common scenarios where this cmdlet shines:
The Get-MgRoleManagementDirectoryRoleAssignment cmdlet is your go-to command for retrieving and analyzing Azure AD directory-level role assignments. It gives you deep visibility into who has access to what — a core part of secure and compliant identity management.
By combining this cmdlet with others like Get-MgRoleManagementDirectoryRoleDefinition and Get-MgUser, you can build a complete picture of your directory’s role landscape.
Stay secure. Stay in control. Start auditing today!
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex