Having read the question on the link here , I would like to get a list of all the names of Azure policies assigned to the tenant irrespective of the scope (subscription, management group etc).
I ran the snippet Get-AzPolicyAssignment | select Name
I had some names, but majority of the names that came back look like guid’s, can anyone please help me with the correct code to work out the actual policy name as displayed on the portal and the scope of the policy ?
I would get output like the below.
ISO Policy xxx
437878sfdf787483eaed87423
However when looking in the portal, they all have proper descriptive names.
2
Answers
You can use the below cmdlet to pull the list and display name’s of the policy assignments that are showing in the portal.
Get-AzPolicyAssignment | Select-Object -ExpandProperty properties | Select-Object -Property DisplayName,Scope | Format-Table
Refer to this sample output screenshot for your reference:
Alternatively, you can use
Azure CLI
commands to check the name and scope of a policy assignment.Output:
Reference: az policy assignment list