ListResourceComplianceSummaries 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

ListResourceComplianceSummaries 搭配 CLI 使用

下列程式碼範例示範如何使用 ListResourceComplianceSummaries

CLI
AWS CLI

若要列出資源層級合規摘要計數

此範例會列出資源層級合規摘要計數。

命令:

aws ssm list-resource-compliance-summaries

輸出:

{ "ResourceComplianceSummaryItems": [ { "ComplianceType": "Association", "ResourceType": "ManagedInstance", "ResourceId": "i-1234567890abcdef0", "Status": "COMPLIANT", "OverallSeverity": "UNSPECIFIED", "ExecutionSummary": { "ExecutionTime": 1550509273.0 }, "CompliantSummary": { "CompliantCount": 2, "SeveritySummary": { "CriticalCount": 0, "HighCount": 0, "MediumCount": 0, "LowCount": 0, "InformationalCount": 0, "UnspecifiedCount": 2 } }, "NonCompliantSummary": { "NonCompliantCount": 0, "SeveritySummary": { "CriticalCount": 0, "HighCount": 0, "MediumCount": 0, "LowCount": 0, "InformationalCount": 0, "UnspecifiedCount": 0 } } }, { "ComplianceType": "Patch", "ResourceType": "ManagedInstance", "ResourceId": "i-9876543210abcdef0", "Status": "COMPLIANT", "OverallSeverity": "UNSPECIFIED", "ExecutionSummary": { "ExecutionTime": 1550248550.0, "ExecutionId": "7abb6378-a4a5-4f10-8312-0123456789ab", "ExecutionType": "Command" }, "CompliantSummary": { "CompliantCount": 397, "SeveritySummary": { "CriticalCount": 0, "HighCount": 0, "MediumCount": 0, "LowCount": 0, "InformationalCount": 0, "UnspecifiedCount": 397 } }, "NonCompliantSummary": { "NonCompliantCount": 0, "SeveritySummary": { "CriticalCount": 0, "HighCount": 0, "MediumCount": 0, "LowCount": 0, "InformationalCount": 0, "UnspecifiedCount": 0 } } } ], "NextToken": "--token string truncated--" }

列出特定合規類型的資源層級合規摘要

此範例列出修補程式合規類型的資源層級合規摘要。

命令:

aws ssm list-resource-compliance-summaries --filters "Key=ComplianceType,Values=Patch,Type=EQUAL"
PowerShell
for PowerShell 工具

範例 1:此範例會取得資源層級摘要計數。摘要包含合規與不合規狀態的相關資訊,以及符合 Windows10 之產品的詳細合規項目嚴重性計數。因為如果未指定 參數,且此值無效,則 MaxResult 預設值為 100,因此會新增 MaxResult 參數,並將值設定為 50。

$FilterValues = @{ "Key"="Product" "Type"="EQUAL" "Values"="Windows10" } Get-SSMResourceComplianceSummaryList -Filter $FilterValues -MaxResult 50