編輯

共用方式為


Start-AzPolicyComplianceScan

Triggers a policy compliance evaluation for all resources in a subscription or resource group.

Syntax

Start-AzPolicyComplianceScan
     [-ResourceGroupName <String>]
     [-AsJob]
     [-PassThru]
     [-DefaultProfile <IAzureContextContainer>]
     [-WhatIf]
     [-Confirm]
     [<CommonParameters>]

Description

The Start-AzPolicyComplianceScan cmdlet starts a policy compliance evaluation for a subscription or resource group. All resources within that scope will have their compliance state evaluated against all assigned policies.

Examples

Example 1: Start a compliance scan at subscription scope

Start-AzPolicyComplianceScan

This command starts a policy compliance evaluation for the active subscription.

Example 2: Start a compliance scan at resource group scope

Start-AzPolicyComplianceScan -ResourceGroupName "myRG"

This command starts a policy compliance evaluation for the "myRG" resource group in the active subscription.

Example 3: Start a compliance scan and wait for it to complete in the background

$job = Start-AzPolicyComplianceScan -AsJob
$job | Wait-Job

This command starts a policy compliance evaluation for the active subscription. It will wait for the scan to complete.

Parameters

-AsJob

Run cmdlet in the background.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-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

-PassThru

Return True if the command completes successfully.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

Resource group name.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Outputs

Boolean