本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
DescribeInstancePatchStatesForPatchGroup
搭配 AWS SDK或 使用 CLI
下列程式碼範例示範如何使用 DescribeInstancePatchStatesForPatchGroup
。
- CLI
-
- AWS CLI
-
範例 1:取得修補程式群組的執行個體狀態
下列
describe-instance-patch-states-for-patch-group
範例會擷取指定修補程式群組的每個執行個體的修補程式摘要狀態詳細資訊。aws ssm describe-instance-patch-states-for-patch-group \ --patch-group
"Production"
輸出:
{ "InstancePatchStates": [ { "InstanceId": "i-02573cafcfEXAMPLE", "PatchGroup": "Production", "BaselineId": "pb-0c10e65780EXAMPLE", "SnapshotId": "a3f5ff34-9bc4-4d2c-a665-4d1c1EXAMPLE", "OwnerInformation": "", "InstalledCount": 32, "InstalledOtherCount": 1, "InstalledPendingRebootCount": 0, "InstalledRejectedCount": 0, "MissingCount": 2, "FailedCount": 0, "UnreportedNotApplicableCount": 2671, "NotApplicableCount": 400, "OperationStartTime": "2021-08-04T11:03:50.590000-07:00", "OperationEndTime": "2021-08-04T11:04:21.555000-07:00", "Operation": "Scan", "RebootOption": "NoReboot", "CriticalNonCompliantCount": 0, "SecurityNonCompliantCount": 1, "OtherNonCompliantCount": 0 }, { "InstanceId": "i-0471e04240EXAMPLE", "PatchGroup": "Production", "BaselineId": "pb-09ca3fb51fEXAMPLE", "SnapshotId": "05d8ffb0-1bbe-4812-ba2d-d9b7bEXAMPLE", "OwnerInformation": "", "InstalledCount": 32, "InstalledOtherCount": 1, "InstalledPendingRebootCount": 0, "InstalledRejectedCount": 0, "MissingCount": 2, "FailedCount": 0, "UnreportedNotApplicableCount": 2671, "NotApplicableCount": 400, "OperationStartTime": "2021-08-04T22:06:20.340000-07:00", "OperationEndTime": "2021-08-04T22:07:11.220000-07:00", "Operation": "Scan", "RebootOption": "NoReboot", "CriticalNonCompliantCount": 0, "SecurityNonCompliantCount": 1, "OtherNonCompliantCount": 0 } ] }
範例 2:取得遺失超過五個修補程式之修補程式群組的執行個體狀態
下列
describe-instance-patch-states-for-patch-group
範例會針對遺失超過五個修補程式的執行個體,擷取指定修補程式群組的修補程式摘要狀態詳細資訊。aws ssm describe-instance-patch-states-for-patch-group \ --filters
Key=MissingCount,Type=GreaterThan,Values=5
\ --patch-group"Production"
輸出:
{ "InstancePatchStates": [ { "InstanceId": "i-02573cafcfEXAMPLE", "PatchGroup": "Production", "BaselineId": "pb-0c10e65780EXAMPLE", "SnapshotId": "a3f5ff34-9bc4-4d2c-a665-4d1c1EXAMPLE", "OwnerInformation": "", "InstalledCount": 46, "InstalledOtherCount": 4, "InstalledPendingRebootCount": 1, "InstalledRejectedCount": 1, "MissingCount": 7, "FailedCount": 0, "UnreportedNotApplicableCount": 232, "NotApplicableCount": 654, "OperationStartTime": "2021-08-04T11:03:50.590000-07:00", "OperationEndTime": "2021-08-04T11:04:21.555000-07:00", "Operation": "Scan", "RebootOption": "NoReboot", "CriticalNonCompliantCount": 0, "SecurityNonCompliantCount": 1, "OtherNonCompliantCount": 1 } ] }
範例 3:為需要重新啟動的執行個體少於十個的修補程式群組取得執行個體狀態
下列
describe-instance-patch-states-for-patch-group
範例會針對執行個體需要重新啟動的少於十個執行個體,擷取指定修補程式群組的修補程式摘要狀態詳細資訊。aws ssm describe-instance-patch-states-for-patch-group \ --filters
Key=InstalledPendingRebootCount,Type=LessThan,Values=10
\ --patch-group"Production"
輸出:
{ "InstancePatchStates": [ { "InstanceId": "i-02573cafcfEXAMPLE", "BaselineId": "pb-0c10e65780EXAMPLE", "SnapshotId": "a3f5ff34-9bc4-4d2c-a665-4d1c1EXAMPLE", "PatchGroup": "Production", "OwnerInformation": "", "InstalledCount": 32, "InstalledOtherCount": 1, "InstalledPendingRebootCount": 4, "InstalledRejectedCount": 0, "MissingCount": 2, "FailedCount": 0, "UnreportedNotApplicableCount": 846, "NotApplicableCount": 212, "OperationStartTime": "2021-08-046T11:03:50.590000-07:00", "OperationEndTime": "2021-08-06T11:04:21.555000-07:00", "Operation": "Scan", "RebootOption": "NoReboot", "CriticalNonCompliantCount": 0, "SecurityNonCompliantCount": 1, "OtherNonCompliantCount": 0 } ] }
如需詳細資訊,請參閱 AWS Systems Manager 使用者指南中的了解修補程式合規狀態值。
-
如需API詳細資訊,請參閱 命令參考 DescribeInstancePatchStatesForPatchGroup
中的 。 AWS CLI
-
- PowerShell
-
- 適用於 的工具 PowerShell
-
範例 1:此範例會取得修補程式群組的每個執行個體的修補程式摘要狀態。
Get-SSMInstancePatchStatesForPatchGroup -PatchGroup "Production"
-
如需API詳細資訊,請參閱 AWS Tools for PowerShell Cmdlet 參考 DescribeInstancePatchStatesForPatchGroup中的 。
-
如需開發人員指南和程式碼範例的完整清單 AWS SDK,請參閱 搭配 使用 Systems Manager AWS SDK。本主題也包含入門的相關資訊,以及先前SDK版本的詳細資訊。