Get-AzPolicyStateSummary
Gets latest policy compliance states summary for resources.
Syntax
SummarizeBySubscriptionId (Default)
Get-AzPolicyStateSummary
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByResourceGroup
Get-AzPolicyStateSummary
-ResourceGroupName <String>
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByPolicySetDefinition
Get-AzPolicyStateSummary
-PolicySetDefinitionName <String>
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByPolicyDefinition
Get-AzPolicyStateSummary
-PolicyDefinitionName <String>
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByPolicyAssignment
Get-AzPolicyStateSummary
-PolicyAssignmentName <String>
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByPolicyAssignmentAndResourceGroup
Get-AzPolicyStateSummary
-ResourceGroupName <String>
-PolicyAssignmentName <String>
[-SubscriptionId <String>]
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByManagementGroup
Get-AzPolicyStateSummary
-ManagementGroupName <String>
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
SummarizeByResourceId
Get-AzPolicyStateSummary
-ResourceId <String>
[-Filter <String>]
[-From <DateTime>]
[-To <DateTime>]
[-Top <Int32>]
[-DefaultProfile <PSObject>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Get-AzPolicyStateSummary cmdlet gets a summary view of latest policy compliance state numbers at various scopes, broken down into policy assignments and policy definitions.
It includes mostly information on 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
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | cf |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-DefaultProfile
The DefaultProfile parameter is not functional. Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
Parameter properties
| Type: | PSObject |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AzureRMContext, AzureCredential |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Filter
Filter expression using OData notation.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-From
ISO 8601 formatted timestamp specifying the start time of the interval to query. When not specified, the service uses ($to - 1-day).
Parameter properties
| Type: | DateTime |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-ManagementGroupName
Management group name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByManagementGroup
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-PolicyAssignmentName
Policy assignment name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByPolicyAssignment
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicyAssignmentAndResourceGroup
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-PolicyDefinitionName
Policy definition name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByPolicyDefinition
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-PolicySetDefinitionName
Policy set definition name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByPolicySetDefinition
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-ResourceGroupName
Resource group name.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByResourceGroup
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicyAssignmentAndResourceGroup
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-ResourceId
Resource ID.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeByResourceId
| Position: | Named |
| Mandatory: | True |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-SubscriptionId
The ID of the target subscription. Uses current subscription if one isn't provided.
Parameter properties
| Type: | String |
| Default value: | (Get-AzContext).Subscription.Id |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
SummarizeBySubscriptionId
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByResourceGroup
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicySetDefinition
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicyDefinition
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicyAssignment
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
SummarizeByPolicyAssignmentAndResourceGroup
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-To
ISO 8601 formatted timestamp specifying the end time of the interval to query. When not specified, the service uses request time.
Parameter properties
| Type: | DateTime |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-Top
Maximum number of records to return.
Parameter properties
| Type: | Int32 |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | wi |
Parameter sets
(All)
| Position: | Named |
| Mandatory: | False |
| Value from pipeline: | False |
| Value from pipeline by property name: | False |
| Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.