The Get-MgDirectoryRoleMember cmdlet retrieves members assigned to a specific directory role in Microsoft Entra ID (previously Azure AD). This helps you audit and manage user and service principal assignments to administrative roles in your tenant.
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Directory.Read.All"
Run the following Graph PowerShell command below to list all members of a directory role. Replace <role-id> with the object ID of the directory role:
Get-MgDirectoryRoleMember -DirectoryRoleId <role-id>
This Graph PowerShell command lists all users and service principals assigned to the specified role:
Get-MgDirectoryRoleMember -DirectoryRoleId "role-object-id"
This Graph PowerShell command limits the output to only 10 members:
Get-MgDirectoryRoleMember -DirectoryRoleId "role-object-id" -Top 10
This Graph PowerShell command filters the output to show only key properties for each member:
Get-MgDirectoryRoleMember -DirectoryRoleId "role-object-id" | Select-Object displayName, userPrincipalName
The following are some essential parameters that can be used along with the Get-MgDirectoryRoleMember command:
| Parameters | Description |
|---|---|
| -DirectoryRoleId | Specifies the directory role object ID to query for members |
| -Top | Limits the number of results returned |
| -Filter | Retrieves only members matching specified criteria |
| -All | Retrieves all results without paging |
| -Property | Selects which properties to return for each member |
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: