PowerShell ile Azure Policy’lerin bir Resource Group icin Uygulanmasi

Oncelikle hangi Policy Definition’in uygulanmasini isteidigimize karar verelim. Bunu icin var olan Policy Definition’lari bir listeleyelim.

Get-AzPolicyDefinition | select -ExpandProperty Properties | select displayname

Yukaridaki komutun listeledigi Policy Definition’lardan hangisini uygulayacaksak tam ismini not edelim.

Sonra da ornek “demo” isimli Resource Group uzerinde bu Policy’yi uygulayalim.

Ben kendi ornegimde “Azure Backup should be enabled for Virtual Machines” isimli Policy Definition’i “demo” isimli RG uzerinde uygulayacagim.

$ResourceGroup = Get-AzResourceGroup -Name ‘demo’

$ResourceGroup = Get-AzResourceGroup -Name ‘demo’
$Policy = Get-AzPolicyDefinition | where{$psitem.properties.displayname -eq ‘Azure Backup should be enabled for Virtual Machines’}
New-AzPolicyAssignment -Name ‘VMler uzerinde yedekleme ozelligi acik olsun’ -PolicyDefinition $Policy -scope $ResourceGroup.ResourceId

Leave a Reply

Your email address will not be published.