How to List Azure role assignments using Azure PowerShell

List role assignments for the current subscription

Get-AzRoleAssignment

List role assignments for a subscription

Get-AzRoleAssignment -Scope /subscriptions/<subscription_id>

Example: PS C:\> Get-AzRoleAssignment -Scope /subscriptions/00000000-0000-0000-0000-000000000000

To list all the roles that are assigned to a specified user and the roles that are assigned to the groups to which the user belongs

Get-AzRoleAssignment -SignInName <email_or_userprincipalname> -ExpandPrincipalGroups

Example - Get-AzRoleAssignment -SignInName isabella@example.com -ExpandPrincipalGroups | FL DisplayName, RoleDefinitionName, Scope

To get only unique display names for the specified sign-in name using the Get-AzRoleAssignment cmdlet in PowerShell and format them as a list,

Get-AzRoleAssignment -SignInName 700753@mgmresorts.com -ExpandPrincipalGroups | Select-Object -ExpandProperty DisplayName -Unique


List role assignments for a resource group

Get-AzRoleAssignment -ResourceGroupName <resource_group_name>

example - Get-AzRoleAssignment -ResourceGroupName pharma-sales | FL DisplayName, RoleDefinitionName, Scope

List role assignments for a resource

Get-AzRoleAssignment -Scope "/subscriptions/<subscription_id>/resourcegroups/<resource_group_name>/providers/<provider_name>/<resource_type>/<resource>

Example - PS C:\> Get-AzRoleAssignment -Scope "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/storage-test-rg/providers/Microsoft.Storage/storageAccounts/storagetest0122"

List role assignments for a managed identity

#Get the object ID of the system-assigned or user-assigned managed identity.

Get-AzADServicePrincipal -DisplayNameBeginsWith "<name> or <vmname>"

#To list the role assignments

Get-AzRoleAssignment -ObjectId <objectid>

Related Posts

Secure supply chain: SBOM, SLSA, signing, provenance (plain English)

If you ship software today, you don’t just ship your code. You ship: That whole chain is your software supply chain. And attackers love it, because instead…

Read More

CI/CD for Cloud Apps: Build → Scan → Deploy → Rollback (a practical reference pipeline)

CI/CD sounds simple until you’re responsible for a production system and realize: This guide gives you a reference CI/CD pipeline you can adopt for most cloud apps…

Read More

Policy as Code: OPA/Rego basics + how it prevents bad infra

You know that feeling when an incident starts with a sentence like: Most “bad infra” isn’t malicious. It’s normal engineering drift:new hires, rushed PRs, copy-paste manifests, unclear…

Read More

Reusable IaC Module Design: naming, inputs/outputs, versioning (the engineer’s playbook)

Reusable IaC modules are like internal libraries: if the “API” is clean, teams move fast. If it’s messy, everyone forks it, patches it, and you end up…

Read More

GitOps explained: Argo CD vs Flux, patterns, and anti-patterns

GitOps is one of those ideas that sounds like buzzwords… until you run it for 30 days and suddenly you can’t imagine operating Kubernetes without it. Because…

Read More

Terraform vs CloudFormation vs Pulumi: which fits which team (the practical, engineer-first guide)

You’re not really choosing a tool. You’re choosing how your team will think about infrastructure for the next 2–5 years: This guide helps you decide fast, without…

Read More
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x