Created
March 10, 2019 07:28
-
-
Save kasunkv/1092abdaea4a1d856719310854638527 to your computer and use it in GitHub Desktop.
Create Azure Policy Assignment using Azure PowerShell
This file contains hidden or 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
# Login to Azure Subscription | |
Login-AzureRmAccount | |
# Get a reference to the resource group | |
$rg = Get-AzureRmResourceGroup -Name "az-policy-rg" | |
# Get a referecen to the Azure Policy Definition | |
$policyDef = Get-AzureRmPolicyDefinition | Where-Object { $_.Properties.DisplayName -eq "Audit VMs that do not use managed disks" } | |
# Create the new Policy Assignment for the Resource Group | |
New-AzureRmPolicyAssignment -Name "Check for Managerd Disks" -DisplayName "Check for Managed Disks" -Scope $rg.ResourceId -PolicyDefinition $policyDef |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment