将 DescribeInstancePatches
与 CLI 配合使用
以下代码示例演示如何使用 DescribeInstancePatches
。
- CLI
-
- AWS CLI
-
示例 1:获取实例的补丁状态详细信息
以下
describe-instance-patches
示例将检索有关指定实例补丁的详细信息。aws ssm describe-instance-patches \ --instance-id
"i-1234567890abcdef0"
输出:
{ "Patches": [ { "Title": "2019-01 Security Update for Adobe Flash Player for Windows Server 2016 for x64-based Systems (KB4480979)", "KBId": "KB4480979", "Classification": "SecurityUpdates", "Severity": "Critical", "State": "Installed", "InstalledTime": "2019-01-09T00:00:00+00:00" }, { "Title": "", "KBId": "KB4481031", "Classification": "", "Severity": "", "State": "InstalledOther", "InstalledTime": "2019-02-08T00:00:00+00:00" }, ... ], "NextToken": "--token string truncated--" }
示例 2:获取实例的处于“缺失”状态的补丁列表
以下
describe-instance-patches
示例检索有关指定实例处于“缺失”状态的补丁的信息。aws ssm describe-instance-patches \ --instance-id
"i-1234567890abcdef0"
\ --filtersKey=State,Values=Missing
输出:
{ "Patches": [ { "Title": "Windows Malicious Software Removal Tool x64 - February 2019 (KB890830)", "KBId": "KB890830", "Classification": "UpdateRollups", "Severity": "Unspecified", "State": "Missing", "InstalledTime": "1970-01-01T00:00:00+00:00" }, ... ], "NextToken": "--token string truncated--" }
有关更多信息,请参阅《AWS Systems Manager 用户指南》中的关于补丁合规性状态。
示例 3:获取实例自指定 InstalledTime 以来所安装补丁的列表
以下
describe-instance-patches
示例通过组合使用--filters
和--query
,检索指定实例自指定时间以来所安装补丁的信息。aws ssm describe-instance-patches \ --instance-id
"i-1234567890abcdef0"
\ --filtersKey=State,Values=Installed
\ --query"Patches[?InstalledTime >= `2023-01-01T16:00:00`]"
输出:
{ "Patches": [ { "Title": "2023-03 Cumulative Update for Windows Server 2019 (1809) for x64-based Systems (KB5023702)", "KBId": "KB5023702", "Classification": "SecurityUpdates", "Severity": "Critical", "State": "Installed", "InstalledTime": "2023-03-16T11:00:00+00:00" }, ... ], "NextToken": "--token string truncated--" }
-
有关 API 详细信息,请参阅《AWS CLI Command Reference》中的 DescribeInstancePatches
。
-
- PowerShell
-
- 适用于 PowerShell 的工具
-
示例 1:此示例获取实例的补丁合规性详细信息。
Get-SSMInstancePatch -InstanceId "i-08ee91c0b17045407"
-
有关 API 详细信息,请参阅《AWS Tools for PowerShell Cmdlet Reference》中的 DescribeInstancePatches。
-
有关 AWS SDK 开发人员指南和代码示例的完整列表,请参阅 将 Systems Manager 与 AWS SDK 配合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
DescribeInstancePatchStatesForPatchGroup
DescribeMaintenanceWindowExecutionTaskInvocations