你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Get-AzPolicyAttestation
获取策略证明。
语法
Get-AzPolicyAttestation
[-Top <Int32>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyAttestation
-Name <String>
[-Scope <String>]
[-ResourceGroupName <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyAttestation
-Scope <String>
[-Top <Int32>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyAttestation
-ResourceGroupName <String>
[-Top <Int32>]
[-Filter <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Get-AzPolicyAttestation
-ResourceId <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
说明
Get-AzPolicyAttestation cmdlet 获取范围或特定证明中的所有策略证明。
示例
示例 1:获取当前订阅中的所有策略证明
Set-AzContext -Subscription "d1acb22b-c876-44f7-b08e-3fcf9f6767f4"
Get-AzPolicyAttestation
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.policyinsights/attestations/
attestation-subscription
Name : attestation-subscription
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationsubassignment
PolicyDefinitionReferenceId :
ComplianceState : NonCompliant
ExpiresOn :
Owner :
Comment : Setting the state to non compliant
Evidence :
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 4:00:04 PM
AssessmentDate :
Metadata :
SystemData :
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/resourcegroups/ps-attestation-test-rg/providers/
microsoft.policyinsights/attestations/attestation-rg
Name : attestation-rg
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationrgassignment
PolicyDefinitionReferenceId :
ComplianceState :
ExpiresOn : 1/27/2024 4:04:24 PM
Owner :
Comment :
Evidence :
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 4:04:11 PM
AssessmentDate :
Metadata :
SystemData :
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/resourcegroups/ps-attestation-test-rg/providers/
microsoft.network/networksecuritygroups/pstests0/providers/microsoft.policyinsights/attestations/att
estation-resource
Name : attestation-resource
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationresourceassignment
PolicyDefinitionReferenceId :
ComplianceState : NonCompliant
ExpiresOn :
Owner : Test Owner 2
Comment :
Evidence :
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 2:38:17 AM
AssessmentDate :
Metadata :
SystemData :
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/resourcegroups/ps-attestation-test-rg/providers/
microsoft.policyinsights/attestations/attestationrgallprops
Name : attestationRGAllProps
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationinitiativergassignment
PolicyDefinitionReferenceId : pstestattestationrg_1
ComplianceState :
ExpiresOn : 1/27/2024 2:51:54 AM
Owner : Test Owner
Comment :
Evidence : {Microsoft.Azure.Commands.PolicyInsights.Models.Attestations.PSAttestationEvidence}
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 2:51:57 AM
AssessmentDate : 1/25/2024 2:51:54 AM
Metadata : {
"TestKey": "TestValue"
}
SystemData :
此命令获取在 ID 为 d1acb22b-c876-44f7-b08e-3fcf9f6767f4 的订阅下创建的所有证明。
示例 2:获取特定策略证明
Get-AzPolicyAttestation -ResourceGroupName "ps-attestation-test-rg" -Name "attestation-RG"
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/resourcegroups/ps-attestation-test-rg/providers/
microsoft.policyinsights/attestations/attestation-rg
Name : attestation-rg
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationrgassignment
PolicyDefinitionReferenceId :
ComplianceState :
ExpiresOn : 1/27/2024 4:04:24 PM
Owner :
Comment :
Evidence :
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 4:04:11 PM
AssessmentDate :
Metadata :
SystemData :
此命令在资源组“ps-attestation-test-rg”处获取名为“attestation-RG”的证明。
示例 3:在包含可选筛选器的订阅中获取 5 个策略证明
Set-AzContext -Subscription "d1acb22b-c876-44f7-b08e-3fcf9f6767f4"
Get-AzPolicyAttestation -Top 5 -Filter "PolicyAssignmentId eq '/subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignments/psattestationresourceassignment'"
Id : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/resourcegroups/ps-attestation-test-rg/providers/
microsoft.network/networksecuritygroups/pstests0/providers/microsoft.policyinsights/attestations/att
estation-resource
Name : attestation-resource
Type : Microsoft.PolicyInsights/attestations
PolicyAssignmentId : /subscriptions/d1acb22b-c876-44f7-b08e-3fcf9f6767f4/providers/microsoft.authorization/policyassignme
nts/psattestationresourceassignment
PolicyDefinitionReferenceId :
ComplianceState : NonCompliant
ExpiresOn :
Owner : Test Owner 2
Comment :
Evidence :
ProvisioningState : Succeeded
LastComplianceStateChangeAt : 1/27/2023 2:38:17 AM
AssessmentDate :
Metadata :
SystemData :
此命令在 ID 为 d1acb22b-c876-44f7-b08e-3fcf9f6767f4 的订阅下获取最多 5 个策略证明。 仅检索给定策略分配的策略证明。
参数
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Filter
使用 OData 表示法筛选表达式。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Name
资源名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ResourceGroupName
资源组名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ResourceId
资源 ID。
类型: | String |
别名: | Id |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Scope
资源的范围。 例如“/subscriptions/{subscriptionId}/resourceGroups/{rgName}”。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Top
要返回的最大记录数。 如果未提供,则返回的最大记录数由 Azure Policy 服务(当前为 1000) 决定。
类型: | Int32 |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |