

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

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

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

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

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

**AWS CLI**  
**列出文档版本**  
以下 `list-document-versions` 示例列出 Systems Manager 文档的所有版本。  

```
aws ssm list-document-versions \
    --name "Example"
```
输出：  

```
{
    "DocumentVersions": [
        {
            "Name": "Example",
            "DocumentVersion": "1",
            "CreatedDate": 1583257938.266,
            "IsDefaultVersion": true,
            "DocumentFormat": "YAML",
            "Status": "Active"
        }
    ]
}
```
有关更多信息，请参阅《AWS Systems Manager 用户指南》**中的[发送使用文档版本参数的命令](https://docs.aws.amazon.com/systems-manager/latest/userguide/run-command-version.html)。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[ListDocumentVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/list-document-versions.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：此示例列出文档的所有版本。**  

```
Get-SSMDocumentVersionList -Name "AWS-UpdateSSMAgent"
```
**输出**：  

```
CreatedDate       : 6/1/2021 5:19:10 PM
DocumentFormat    : JSON
DocumentVersion   : 1
IsDefaultVersion  : True
Name              : AWS-UpdateSSMAgent
Status            : Active
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [ListDocumentVersions](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例列出文档的所有版本。**  

```
Get-SSMDocumentVersionList -Name "AWS-UpdateSSMAgent"
```
**输出**：  

```
CreatedDate       : 6/1/2021 5:19:10 PM
DocumentFormat    : JSON
DocumentVersion   : 1
IsDefaultVersion  : True
Name              : AWS-UpdateSSMAgent
Status            : Active
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [ListDocumentVersions](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------