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:
1 2 3 4 5 |
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!
You have forgot to assign the 4th line in $sub variable 🙂