The Get-MgServicePrincipalAppRoleAssignment cmdlet retrieves the app role assignments granted to a specified service principal in Microsoft Entra ID (previously Azure AD). App role assignments are delegated permissions granted to service principals (applications), allowing them to access specific application roles or APIs.
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "AppRoleAssignment.Read.All"
Run the cmdlet below in Microsoft Graph PowerShell to retrieve all application role assignments of a service principal. Replace <service-principal-id> with the actual service principal object ID:
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId <service-principal-id>
This Graph PowerShell command retrieves all application role assignments associated with the specified service principal ID:
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "01234567-89ab-cdef-0123-456789abcdef"
This Graph PowerShell command filters the assignments to display only those with the specified resource (target application) ID:
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "01234567-89ab-cdef-0123-456789abcdef" -Filter "resourceId eq 'fedcba98-7654-3210-fedc-ba9876543210'"
The following are some essential parameters that can be used along with the Get-MgServicePrincipalAppRoleAssignment cmdlet:
| Parameters | Description |
|---|---|
| -ServicePrincipalId | Specifies the ID of the service principal to query |
| -Top | Limits the number of results returned in the output |
| -Filter | Filters the results based on specified criteria |
| -All | Retrieves all results without paging (if supported) |
| -Property | Selects specific properties to be returned in the output |
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: