Created
January 5, 2019 01:18
-
-
Save mmckechney/f1b4171a0d3621a9937bde069905d009 to your computer and use it in GitHub Desktop.
PowerShell Script to create an advanced user for Azure DevTest Labs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$subscriptionId = "<insert your subscription id here>" | |
$policyRoleDef = (Get-AzureRmRoleDefinition "DevTest Labs User") | |
$policyRoleDef.Actions.Remove('Microsoft.DevTestLab/Environments/*') | |
$policyRoleDef.Id = $null | |
$policyRoleDef.Name = "DevTest Labs Advanced User" | |
$policyRoleDef.Description = "Lets you connect, start, restart, shutdown and resize ALL virtual machines in your Azure DevTest Labs." | |
$policyRoleDef.IsCustom = $true | |
$policyRoleDef.AssignableScopes.Clear() | |
$policyRoleDef.AssignableScopes.Add("/subscriptions/$($subscriptionId )") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/Start/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/Stop/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/write") | |
$policyRoleDef.Actions.Add("microsoft.devtestlab/labs/virtualmachines/resize/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/customImages/*") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/users/disks/read") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/users/disks/write") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/users/disks/Attach/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/users/disks/Detach/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/AddDataDisk/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/ApplyArtifacts/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/DetachDataDisk/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/Restart/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/TransferDisks/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/Redeploy/action") | |
$policyRoleDef.Actions.Add("Microsoft.DevTestLab/labs/virtualMachines/UnClaim/action") | |
New-AzureRmRoleDefinition -Role $policyRoleDef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment