Skip to content

Commit dee07ec

Browse files
varunkumtaisra-fel
andauthored
[Policy] Adding examples for retrieving component-level policy compliance states (Azure#16347)
* Doc updates for component compliance * Update ChangeLog * Address comments - 1 * Revert changelog because not necessary Co-authored-by: Yeming Liu <[email protected]>
1 parent 33374d9 commit dee07ec

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/PolicyInsights/PolicyInsights/help/Get-AzPolicyState.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,29 @@ PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-ff
242242

243243
Gets latest policy state records generated in the last day for the specified resource and expand policyEvaluationDetails.
244244

245+
### Example 23: Get latest component policy states for a resource (eg. vault) given a resource provider mode policy assignment
246+
```powershell
247+
PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myvault" - Filter "policyAssignmentId eq '/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ddd8ef92e3714a5ea3d208c1'" -Expand "Components(`$filter=ComplianceState eq 'NonCompliant' or ComplianceState eq 'Compliant')"
248+
```
249+
250+
Gets latest component policy state records generated in the last day for the specified resource, given a resource provider mode policy assignment that references a resource provider mode policy definition.
251+
252+
253+
### Example 24: Get latest component policy states for a resource (eg. vault) given a policy initiative assignment that contains a resource provider mode policy definition
254+
```powershell
255+
PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myvault" - Filter "policyAssignmentId eq '/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ddd8ef92e3714a5ea3d208c1' and policyDefinitionReferenceId eq 'myResourceProviderModeDefinitionReferenceId'" -Expand "Components(`$filter=ComplianceState eq 'NonCompliant' or ComplianceState eq 'Compliant')"
256+
```
257+
258+
Gets latest component policy state records generated in the last day for the specified resource, given a resource provider mode policy assignment that references an initiative containing a resource provider mode policy definition.
259+
260+
261+
### Example 25: Get latest component counts by compliance state for a resource (eg. vault) given a resource provider mode policy assignment
262+
```powershell
263+
PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myvault" - Filter "policyAssignmentId eq '/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/providers/Microsoft.Authorization/policyAssignments/ddd8ef92e3714a5ea3d208c1'" -Expand "Components(`$filter=ComplianceState eq 'NonCompliant' or ComplianceState eq 'Compliant' or ComplianceState eq 'Conflict';`$apply=groupby((complianceState),aggregate(`$count as count)))"
264+
```
265+
266+
Gets latest component counts generated in the last day grouped by compliance state for the specified resource, given a resource provider mode policy assignment.
267+
245268

246269
## PARAMETERS
247270

0 commit comments

Comments
 (0)