Azure PowerShell: How to assign access to a subscription using PowerShell (RBAC)

I had this question from a customer recently, and when I searched the net I wouldn’t find any specific examples.

This example assigns a user as a Contributor to the subscription.

When you assign roles to resources, all you need is the URL for the resource and provide it to this cmdlet.

Here you go:

Login-AzureRMAccount
$userEmail = "test@example.com"
$SubscriptionName = "Test Subscription"
Get-AzureRmSubscription -Subscriptionname $SubscriptionName
New-AzureRmRoleAssignment -SignInName $userEmail  -Scope "/subscriptions/$($sub.SubscriptionId)" -RoleDefinitionName Contributor

That’s all for today!


Leave a Reply