Yogesh Kulkarni
Yogesh Kulkarni

Reputation: 359

How to get Azure Policy compliance report using PowerShell for a specific Resource and for a specific policy?

I want to get the Azure Policy Compliance report for a particular resource and for a particular policy. How to achieve this using PowerShell? e.g. for a Azure VM and for a custom policy "Deny-Firewall".

Upvotes: 0

Views: 4013

Answers (1)

Jim Xu
Jim Xu

Reputation: 23141

If you want to get the Azure Policy Compliance data with PowerShell, please refer to the following script

  1. Get data for a particular policy
# get the policy compliance status
 Get-AzPolicyState -PolicyDefinitionName <the policy definitionName>

# get the policy evaluation result
Get-AzPolicyEvent -PolicyDefinitionName <the policy definitionName>

2.1. Get data for a particular resource

# get the policy compliance status
 Get-AzPolicyState -ResourceId <>

# get the policy evaluation result
Get-AzPolicyEvent -ResourceId <>

For more details, please refer to here

Upvotes: 0

Related Questions