Export the data of Policy Assignments Name, Type (Intiatives or Policy), Scope and then for each Policy Assignments I need the policy definitions Version, category, type associated with it and export in excel file

J.I. PRASHANDH 0 Reputation points
2024-09-03T12:53:20.3766667+00:00

Hello Team,

Can any one help on how I can Export the data of Policy Assignments Name, Type (Intiatives or Policy), Scope and then for each Policy Assignments I need the policy definitions Version, category, type associated with it and export in excel file.

Any KQL Query or Powershell script that helps.

Thank YOU...

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
868 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. J.I. PRASHANDH 0 Reputation points
    2024-09-04T05:33:34.9533333+00:00

    Any can update and guide me on this

    0 comments No comments

  2. Prashant Kumar 775 Reputation points Microsoft Employee
    2024-09-04T06:40:33.0966667+00:00

    Hi J.I PRASHANDH

    You can use policyresources table in Azure Resource graph to get policy assignments, definitions and setdefinitions(initiative) details.

    You will get most of your fields from policyassignments type but to get more information about related policy definitions or setdefinitions, you will have to use join between these three types.

    https://video2.skills-academy.com/en-us/azure/governance/policy/samples/resource-graph-samples?tabs=azure-cli

    Sample ARG query:

    policyresources
    | where type == "microsoft.authorization/policyassignments"
    | project id,name,subscriptionId,policyDefinitionId =(properties.policyDefinitionId),scope = (properties.scope),definitionVersion=(properties.definitionVersion)
    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.