I'm trying to get the list of all policy assignments created in azure using the below commands.
However when I scope the assignment to the resource group, below command does not return that assignment in its output. Please advise on this further.
Powershell commands:
To get all policy assignment:
Get-AzPolicyAssignment
This commands return list of assignments scoped to only subscriptions & management groups
To get specific policy assignment which is scoped to resource group:
$ResourceGroup = Get-AzResourceGroup -Name 'ResourceGroup01'
Get-AzPolicyAssignment -Name 'PolicyAssignment01' -Scope $ResourceGroup.ResourceId
This commands does not return any policy assignment
Reference links: