Share via


Quick Script: List Role-Based Access Control (RBAC) Assignments for Azure Resources via PowerShell

Role-Based Access Control (RBAC) is a great new feature of Azure Resource Manager and the Azure Preview Portal for delegating granular access to Azure resources. 

Access Control

Recently, I was asked for an easy way to enumerate the list of resources to which a particular user is assigned.  In this article, I’ll provide a brief code snippet using the latest version of the Azure PowerShell module that quickly lists the RBAC assignments for a user …

List Azure RBAC Assignments for a User via PowerShell

# Authenticate with Azure Account

Add-AzureAccount

# Select Azure Subscription

Select-AzureSubscription `
-Name "Subscription Name"

# Switch to Azure Resource Manager Mode

Switch-AzureMode `
-Name AzureResourceManager

# List RBAC assignments for an Azure AD User

Get-AzureRoleAssignment `
-UserPrincipalName "user@contoso.com" |
Format-Table Scope, RoleDefinitionName