Unable to assign policy from Azure Powershell

%3CLINGO-SUB%20id%3D%22lingo-sub-2735007%22%20slang%3D%22en-US%22%3EUnable%20to%20assign%20policy%20from%20Azure%20Powershell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2735007%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20Assign%20policy%20using%20the%20Azure%20Powershell%20to%20the%20resource%20group%3C%2FP%3E%3CP%3EFirst%20Creating%20RG-----------------------%3CBR%20%2F%3E%24rg%3DNew-AzResourceGroup%20-Name%20%22My_New_resource_Group%22%20-Location%20%22East%20Us%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESecond%20Assigning%20Policy%20definition------------------%3CBR%20%2F%3E%24Document%3DGet-AzPolicyDefinition%20%7C%20Where-Object%7B%24_.Properties.DisplayName%20-eq%20%22Audit%20Missing%20tagss%20on%20Resource%20Groups%22%7D%3C%2FP%3E%3CP%3EThird%20Assigning%20policy%20to%20the%20RG-------------------------%3CBR%20%2F%3ENew-AzPolicyAssignment%20-Name%20%22CheckPolicy%22%20-DisplayName%20%22Check%20Policy%22%20-Scope%20%24rg.ResourceId%20-PolicyDefinition%20%24Document%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3Ebut%20I%20get%20this%20prompt%20asking%20for%20the%20allowed%20locations(%20Attached%20screenshot%20)%20.%20How%20to%20resolve%20this%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2735007%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

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?