Open evanrappe opened 3 years ago
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kenieva.
Author: | bsod99 |
---|---|
Assignees: | - |
Labels: | `Policy Insights`, `Service Attention`, `question`, `customer-reported` |
Milestone: | - |
Policy Insights team, please look into this feature question.
Investigating...
@evanrappe Apologies for the late reply. Could you please use the Get-AzPolicyState cmdlet and test if that serves your requirement ?
Get-AzPolicyState -Filter "ComplianceState eq 'Compliant'"
Awaiting your reply.
@navba-MSFT I think with a bit of local filtering and counting I could get to where we needed for this, but it feels inefficient. It would be great if Get-AzPolicyStateSummary
reported both compliant/noncompliant counts for a given assignment ID like az policy state summarize
Am I missing something, are these two not supposed to be equivalent commands?
My apologies -- been a while since I worked on this one. I believe the reason I had originally decided to use the "Summary" commands to get what I needed was because Get-AzPolicyState
only outputs 1000 results, thus making filtering and counting with this command unusable for this case.
@evanrappe At what scope are you making this request? and its just for one particular assignment ID? I want to see if I can reproduce the issue on my side.
@kenieva Yeah, it's just for one assignment ID, but I'm making this request on a management group above all subscriptions, so there's unfortunately far more than 1000 results.
Can you post the full query you are using? (expect for any MGNames, or other customer data).
To see that Get-AzPolicyState
was capped at 1000 results, I used:
(Get-AzPolicyState -ManagementGroupName MGname -Filter "(policyAssignmentId eq '/providers/Microsoft.Management/managementGroups/MGname/providers/Microsoft.Authorization/policyAssignments/policyAssignmentID')").count
To see that `Get-AzPolicyStateSummary isn't returning the noncompliant count like az policy state summarize does, I used:
get-azpolicystatesummary -managementgroupname "MGname" -filter "(policyAssignmentId eq '/providers/Microsoft.Management/managementGroups/MGname/providers/Microsoft.Authorization/policyAssignments/policyAssignmentID')"
Get-AzPolicyStateSummary
does not return compliant resource countPer the docs this is by design, but why?
For metric/KPI purposes it is required to know both compliant and noncompliant totals for a given assignment. The equivalent azcli command
az policy state summarize
returns both values, but PowerShell does not.