

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

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

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

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

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

**AWS CLI**  
**示例 1：列出所有维护时段**  
以下`describe-maintenance-windows`示例列出了当前区域中您 AWS 账户中的所有维护时段。  

```
aws ssm describe-maintenance-windows
```
输出：  

```
{
    "WindowIdentities": [
        {
            "WindowId": "mw-0ecb1226ddEXAMPLE",
            "Name": "MyMaintenanceWindow-1",
            "Enabled": true,
            "Duration": 2,
            "Cutoff": 1,
            "Schedule": "rate(180 minutes)",
            "NextExecutionTime": "2020-02-12T23:19:20.596Z"
        },
        {
            "WindowId": "mw-03eb9db428EXAMPLE",
            "Name": "MyMaintenanceWindow-2",
            "Enabled": true,
            "Duration": 3,
            "Cutoff": 1,
            "Schedule": "rate(7 days)",
            "NextExecutionTime": "2020-02-17T23:22:00.956Z"
        },
    ]
}
```
**示例 2：列出所有已启用的维护时段**  
以下 `describe-maintenance-windows` 示例列出所有已启用的维护时段。  

```
aws ssm describe-maintenance-windows \
    --filters "Key=Enabled,Values=true"
```
**示例 3：列出与特定名称匹配的维护时段**  
此 `describe-maintenance-windows` 示例列出具有指定名称的所有维护时段。  

```
aws ssm describe-maintenance-windows \
    --filters "Key=Name,Values=MyMaintenanceWindow"
```
有关更多信息，请参阅《S *AWS ystems Manager 用户指南》*中的 “[查看有关维护窗口的信息 (AWS CLI)](https://docs.aws.amazon.com/systems-manager/latest/userguide/maintenance-windows-cli-tutorials-describe.html)”。  
+  有关 API 的详细信息，请参阅*AWS CLI 命令参考[DescribeMaintenanceWindows](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/describe-maintenance-windows.html)*中的。

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

**适用于 PowerShell V4 的工具**  
**示例 1：此示例列出您账户中的所有维护时段。**  

```
Get-SSMMaintenanceWindowList
```
**输出**：  

```
Cutoff   : 1
Duration : 4
Enabled  : True
Name     : My-First-Maintenance-Window
WindowId : mw-06d59c1a07c022145
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 4) [DescribeMaintenanceWindows](https://docs.aws.amazon.com/powershell/v4/reference)中的。

**适用于 PowerShell V5 的工具**  
**示例 1：此示例列出您账户中的所有维护时段。**  

```
Get-SSMMaintenanceWindowList
```
**输出**：  

```
Cutoff   : 1
Duration : 4
Enabled  : True
Name     : My-First-Maintenance-Window
WindowId : mw-06d59c1a07c022145
```
+  有关 API 的详细信息，请参阅 *AWS Tools for PowerShell Cmdlet 参考 (V* 5) [DescribeMaintenanceWindows](https://docs.aws.amazon.com/powershell/v5/reference)中的。

------