skip to Main Content

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


  1. 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:

    enter image description here

    Login or Signup to reply.
  2. 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 ?

    Alternatively, you can use Azure CLI commands to check the name and scope of a policy assignment.

     az policy assignment list --query '[].{AssignmentName: displayName, Scope: scope}' --output table
    

    Output:

    enter image description here

    Reference: az policy assignment list

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search