

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将 `DescribePatchGroupState` 与 CLI 配合使用
<a name="ssm_example_ssm_DescribePatchGroupState_section"></a>

以下代码示例演示如何使用 `DescribePatchGroupState`。

------
#### [ CLI ]

**AWS CLI**  
**获取补丁组的状态**  
以下 `describe-patch-group-state` 示例检索补丁组的高级补丁合规性摘要。  

```
aws ssm describe-patch-group-state \
    --patch-group "Production"
```
输出：  

```
{
    "Instances": 21,
    "InstancesWithCriticalNonCompliantPatches": 1,
    "InstancesWithFailedPatches": 2,
    "InstancesWithInstalledOtherPatches": 3,
    "InstancesWithInstalledPatches": 21,
    "InstancesWithInstalledPendingRebootPatches": 2,
    "InstancesWithInstalledRejectedPatches": 1,
    "InstancesWithMissingPatches": 3,
    "InstancesWithNotApplicablePatches": 4,
    "InstancesWithOtherNonCompliantPatches": 1,
    "InstancesWithSecurityNonCompliantPatches": 1,
    "InstancesWithUnreportedNotApplicablePatches": 2
}
```
*有关更多信息，请参阅 Systems Manager 用户指南中的关于补丁组 < https://docs.aws.amazon.com/systems-manager/ latest/userguide/sysman-patch-patchgroups.html>\$1\$1 和了解补丁[合规性状态值](https://docs.aws.amazon.com/systems-manager/latest/userguide/about-patch-compliance-states.html)。AWS *  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribePatchGroupState](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/describe-patch-group-state.html)*中的。

------
#### [ PowerShell ]

**适用于 PowerShell V4 的工具**  
**示例 1：此示例获取补丁组的高级补丁合规性摘要。**  

```
Get-SSMPatchGroupState -PatchGroup "Production"
```
**输出**：  

```
Instances                          : 4
InstancesWithFailedPatches         : 1
InstancesWithInstalledOtherPatches : 4
InstancesWithInstalledPatches      : 3
InstancesWithMissingPatches        : 0
InstancesWithNotApplicablePatches  : 0
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [DescribePatchGroupState](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例获取补丁组的高级补丁合规性摘要。**  

```
Get-SSMPatchGroupState -PatchGroup "Production"
```
**输出**：  

```
Instances                          : 4
InstancesWithFailedPatches         : 1
InstancesWithInstalledOtherPatches : 4
InstancesWithInstalledPatches      : 3
InstancesWithMissingPatches        : 0
InstancesWithNotApplicablePatches  : 0
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribePatchGroupState](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------