Skip to content

Instantly share code, notes, and snippets.

@PCfromDCSnippets
Created December 15, 2017 16:59
Show Gist options
  • Save PCfromDCSnippets/baf223c047173133be9fcb270739a13e to your computer and use it in GitHub Desktop.
Save PCfromDCSnippets/baf223c047173133be9fcb270739a13e to your computer and use it in GitHub Desktop.
Add User to Azure Access Control
Param (
[string]$subscriptionName = "mySubscription",
[string]$resourceGroupName = "Networking",
[string]$localGatewayName = "LocalGateway",
[string]$userID = "508bb5e1-898e-user-9a71-47de815db2af"
)
Login-AzureRmAccount -SubscriptionName $subscriptionName
$ID = Get-AzureRmResourceGroup $resourceGroup1 | Get-AzureRmLocalNetworkGateway -Name $localGatewayName | select Id
New-AzureRmRoleAssignment -Scope $ID.Id -ObjectId $userID -RoleDefinitionName "Contributor"
<# Remove User from EVERYWHERE!
Get-AzureRmRoleAssignment | Where-Object {$_.ObjectId -eq $userID} | Remove-AzureRmRoleAssignment
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment