PowerShell Genie

Report Azure role assignments

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Report Azure role assignments with Get-AzRoleAssignment, including principal identity, role, scope, and object type in the active context.

The script

1PS> Get-AzRoleAssignment | Select-Object DisplayName,SignInName,RoleDefinitionName,Scope,ObjectType

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 DisplayName SignInName RoleDefinitionName Scope ObjectType
    2 ----------- ---------- ------------------ ----- ----------
    3 Sample object user@example.test Reader /subscriptions/00000000 User
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-AzRoleAssignment | Select-Object DisplayName,SignInName,RoleDefinitionName,Scope,ObjectType
    1. Stage 1Get-AzRoleAssignmentPositional values or no named parameters
    2. Stage 2Select-ObjectPositional values or no named parameters

      How it works

      Get-AzRoleAssignment retrieves the assignments visible to the current context, and the projection pairs each principal's display name and sign-in name with the role definition, the scope string the assignment applies at, and ObjectType, which separates a user from a group or a service principal.

      Adapting it

      Narrow the query with -Scope to one resource group, or add -IncludeClassicAdministrators when auditing an older subscription that may still carry co-administrators.

      Requirements

      Az.Resources with a session holding roleAssignments read plus directory read for name resolution.

      If the result is unexpected

      The role-assignment report appears to omit effective access.

      Scope inheritance, group membership and eligible role activation can differ from direct assignments.

      1. Record the queried scope and inspect a known principal's assignment and inheritance path.

      Validate the result

      Rows identify principal, role and scope without claiming to capture every source of effective access.

      Keep the check reliable

      Separate direct assignments, inherited access and eligible roles in access reviews.

      Primary documentation

      PowerShell objects and pipelines documentation

      Continue
      Genie guideReport Azure role assignments

      Report Azure role assignments with Get-AzRoleAssignment, including principal identity, role, scope, and object type in the active context.