Skip to content

Commit 89fa7d8

Browse files
authored
Update Get-AzPolicyState.md (#15455)
Corrected the explanation for example 21 and 22
1 parent 64b0e3e commit 89fa7d8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,21 @@ This generates the list of all resources within the subscription that are non-co
228228
PS C:\> Get-AzPolicyState -Filter "ComplianceState eq 'NonCompliant'" -Apply "groupby((PolicyAssignmentId, PolicySetDefinitionId, PolicyDefinitionReferenceId, PolicyDefinitionId, ResourceId))/groupby((PolicyAssignmentId, PolicySetDefinitionId, PolicyDefinitionReferenceId, PolicyDefinitionId), aggregate(`$count as NumNonCompliantResources))" -OrderBy "NumNonCompliantResources desc" -Top 5
229229
```
230230

231-
### Example 22: Get latest policy states including policy evaluation details for a resource
232-
```powershell
233-
PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.EventHub/namespaces/myns1/eventhubs/eh1/consumergroups/cg1" -Expand "PolicyEvaluationDetails"
234-
```
235-
236231
Gets latest policy state records generated in the last day for all resources within the subscription in current session context.
237232
The command limits the results returned by filtering based on compliance status (includes only non-compliant status).
238233
It groups the results first based on policy assignment, policy set definition, policy definition, and resource id.
239234
Then, it further groups the results of this grouping with the same properties except for resource id, and computes the number of records in each of these groups, which is returned inside AdditionalProperties property.
240235
It orders the results by the count aggregation in descending order, and takes only top 5 of those listed in that order.
241236
This generates the top 5 policies with the most number of non-compliant resources.
242237

238+
### Example 22: Get latest policy states including policy evaluation details for a resource
239+
```powershell
240+
PS C:\> Get-AzPolicyState -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.EventHub/namespaces/myns1/eventhubs/eh1/consumergroups/cg1" -Expand "PolicyEvaluationDetails"
241+
```
242+
243+
Gets latest policy state records generated in the last day for the specified resource and expand policyEvaluationDetails.
244+
245+
243246
## PARAMETERS
244247

245248
### -All

0 commit comments

Comments
 (0)