Unable to assign policy from Azure Powershell

Copper Contributor

Hi ,

I am trying to Assign policy using the Azure Powershell to the resource group

First Creating RG-----------------------
$rg=New-AzResourceGroup -Name "My_New_resource_Group" -Location "East Us"

 

Second Assigning Policy definition------------------
$Document=Get-AzPolicyDefinition | Where-Object{$_.Properties.DisplayName -eq "Audit Missing tagss on Resource Groups"}

Third Assigning policy to the RG-------------------------
New-AzPolicyAssignment -Name "CheckPolicy" -DisplayName "Check Policy" -Scope $rg.ResourceId -PolicyDefinition $Document




but I get this prompt asking for the allowed locations( Attached screenshot ) . How to resolve this

 

 

 

1 Reply
It seems your policy definition has a parameter (alllowedLocations) that needs to be populated with some value during the policy assignment. Since there is no built-in policy with a display name you specified, I assume you (or someone else in your org) created a custom policy.

Can you share the JSON representation of that policy definition?