Get-AzPolicyStateSummary
Gets latest policy compliance states summary for resources.
Syntax
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
-ManagementGroupName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
-ResourceGroupName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
-PolicySetDefinitionName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
-PolicyDefinitionName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
-PolicyAssignmentName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
-ResourceGroupName <String>
-PolicyAssignmentName <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyStateSummary
-ResourceId <String>
[-Top <Int32>]
[-From <DateTime>]
[-To <DateTime>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
Gets a summary view of latest policy compliance state numbers at various scopes, broken down into policy assignments and policy definitions. It includes only non-compliant policy states.
Examples
Example 1: Get latest non-compliant policy states summary in current subscription scope
Get-AzPolicyStateSummary
Gets the summary view of latest policy compliance states generated in the last day for all resources within the subscription in current session context.
Example 2: Get latest non-compliant policy states summary in the specified subscription scope
Get-AzPolicyStateSummary -SubscriptionId "fff10b27-fff3-fff5-fff8-fffbe01e86a5"
Gets the summary view of latest policy compliance states generated in the last day for all resources within the specified subscription.
Example 3: Get latest non-compliant policy states summary in management group scope
Get-AzPolicyStateSummary -ManagementGroupName "myManagementGroup"
Gets the summary view of latest policy compliance states generated in the last day for all resources within the specified management group.
Example 4: Get latest non-compliant policy states summary in resource group scope in current subscription
Get-AzPolicyStateSummary -ResourceGroupName "myResourceGroup"
Gets the summary view of latest policy compliance states generated in the last day for all resources within the specified resource group (in the subscription in current session context).
Example 5: Get latest non-compliant policy states summary in resource group scope in the specified subscription
Get-AzPolicyStateSummary -SubscriptionId "fff10b27-fff3-fff5-fff8-fffbe01e86a5" -ResourceGroupName "myResourceGroup"
Gets the summary view of latest policy compliance states generated in the last day for all resources within the specified resource group (in the specified subscription).
Example 6: Get latest non-compliant policy states summary for a resource
Get-AzPolicyStateSummary -ResourceId "/subscriptions/fff10b27-fff3-fff5-fff8-fffbe01e86a5/resourceGroups/myResourceGroup/providers/Microsoft.EventHub/namespaces/myns1/eventhubs/eh1/consumergroups/cg1"
Gets the summary view of latest policy compliance states generated in the last day for the specified resource.
Example 7: Get latest non-compliant policy states summary for a policy set definition in current subscription
Get-AzPolicyStateSummary -PolicySetDefinitionName "fff58873-fff8-fff5-fffc-fffbe7c9d697"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy set definition (that exists in the subscription in current session context).
Example 8: Get latest non-compliant policy states summary for a policy set definition in the specified subscription
Get-AzPolicyStateSummary -SubscriptionId "fff10b27-fff3-fff5-fff8-fffbe01e86a5" -PolicySetDefinitionName "fff58873-fff8-fff5-fffc-fffbe7c9d697"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy set definition (that exists in the specified subscription).
Example 9: Get latest non-compliant policy states summary for a policy definition in current subscription
Get-AzPolicyStateSummary -PolicyDefinitionName "fff58873-fff8-fff5-fffc-fffbe7c9d697"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy definition (that exists in the subscription in current session context).
Example 10: Get latest non-compliant policy states summary for a policy definition in the specified subscription
Get-AzPolicyStateSummary -SubscriptionId "fff10b27-fff3-fff5-fff8-fffbe01e86a5" -PolicyDefinitionName "fff58873-fff8-fff5-fffc-fffbe7c9d697"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy definition (that exists in the specified subscription).
Example 11: Get latest non-compliant policy states summary for a policy assignment in current subscription
Get-AzPolicyStateSummary -PolicyAssignmentName "ddd8ef92e3714a5ea3d208c1"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy assignment (that exists in the subscription in current session context).
Example 12: Get latest non-compliant policy states summary for a policy assignment in the specified subscription
Get-AzPolicyStateSummary -SubscriptionId "fff10b27-fff3-fff5-fff8-fffbe01e86a5" -PolicyAssignmentName "ddd8ef92e3714a5ea3d208c1"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy assignment (that exists in the specified subscription).
Example 13: Get latest non-compliant policy states summary for a policy assignment in the specified resource group in the current subscription
Get-AzPolicyStateSummary -ResourceGroupName "myResourceGroup" -PolicyAssignmentName "ddd8ef92e3714a5ea3d208c1"
Gets the summary view of latest policy compliance states generated in the last day for all resources (within the tenant in current session context) effected by the specified policy assignment (that exists in the resource group in the subscription in current session context).
Example 14: Get latest non-compliant policy states summary in current subscription scope, with Top query option
Get-AzPolicyStateSummary -Top 5
Gets the summary view of latest policy compliance states generated in the last day for all resources within the subscription in current session context. The command orders the policy assignment summaries in the results by non-compliant resource counts in descending order, and takes only top 5 of those policy assignment summaries.
Example 15: Get latest non-compliant policy states summary in current subscription scope, with From and To query options
Get-AzPolicyStateSummary -From "2018-03-08 00:00:00Z" -To "2018-03-15 00:00:00Z"
Gets the summary view of latest policy compliance states generated within the date range specified for all resources within the subscription in current session context.
Example 16: Get latest non-compliant policy states summary in current subscription scope, with Filter query option
Get-AzPolicyStateSummary -Filter "(PolicyDefinitionAction eq 'deny' or PolicyDefinitionAction eq 'audit') and ResourceLocation ne 'eastus'"
Gets the summary view of latest policy compliance states generated in the last day for all resources within the subscription in current session context. The command limits the results returned by filtering based on policy definition action (includes deny or audit actions), and resource location (excludes eastus location).
Parameters
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Filter
Filter expression using OData notation.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-From
ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, defaults to 'To' parameter value minus 1 day.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ManagementGroupName
Management group name.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PolicyAssignmentName
Policy assignment name.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PolicyDefinitionName
Policy definition name.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-PolicySetDefinitionName
Policy set definition name.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceGroupName
Resource group name.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ResourceId
Resource ID.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SubscriptionId
Subscription ID.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-To
ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, defaults to time of request.
Type: | DateTime |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Top
Maximum number of records to return.
Type: | Int32 |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Outputs
Related Links
Azure PowerShell