DescribeMaintenanceWindowExecutions与 a 一起使用 CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

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

DescribeMaintenanceWindowExecutions与 a 一起使用 CLI

以下代码示例演示如何使用 DescribeMaintenanceWindowExecutions

CLI
AWS CLI

示例 1:列出维护时段内的所有执行

以下 describe-maintenance-window-executions 示例列出指定维护时段的所有执行。

aws ssm describe-maintenance-window-executions \ --window-id "mw-ab12cd34eEXAMPLE"

输出:

{ "WindowExecutions": [ { "WindowId": "mw-ab12cd34eEXAMPLE", "WindowExecutionId": "6027b513-64fe-4cf0-be7d-1191aEXAMPLE", "Status": "IN_PROGRESS", "StartTime": "2021-08-04T11:00:00.000000-07:00" }, { "WindowId": "mw-ab12cd34eEXAMPLE", "WindowExecutionId": "ff75b750-4834-4377-8f61-b3cadEXAMPLE", "Status": "SUCCESS", "StartTime": "2021-08-03T11:00:00.000000-07:00", "EndTime": "2021-08-03T11:37:21.450000-07:00" }, { "WindowId": "mw-ab12cd34eEXAMPLE", "WindowExecutionId": "9fac7dd9-ff21-42a5-96ad-bbc4bEXAMPLE", "Status": "FAILED", "StatusDetails": "One or more tasks in the orchestration failed.", "StartTime": "2021-08-02T11:00:00.000000-07:00", "EndTime": "2021-08-02T11:22:36.190000-07:00" } ] }

示例 2:列出指定日期之前维护时段内的所有执行

以下 describe-maintenance-window-executions 示例列出指定日期之前指定维护时段内的所有执行。

aws ssm describe-maintenance-window-executions \ --window-id "mw-ab12cd34eEXAMPLE" \ --filters "Key=ExecutedBefore,Values=2021-08-03T00:00:00Z"

输出:

{ "WindowExecutions": [ { "WindowId": "mw-ab12cd34eEXAMPLE", "WindowExecutionId": "9fac7dd9-ff21-42a5-96ad-bbc4bEXAMPLE", "Status": "FAILED", "StatusDetails": "One or more tasks in the orchestration failed.", "StartTime": "2021-08-02T11:00:00.000000-07:00", "EndTime": "2021-08-02T11:22:36.190000-07:00" } ] }

示例 3:列出指定日期之后维护时段内的所有执行

以下 describe-maintenance-window-executions 示例列出指定日期之后指定维护时段内的所有执行。

aws ssm describe-maintenance-window-executions \ --window-id "mw-ab12cd34eEXAMPLE" \ --filters "Key=ExecutedAfter,Values=2021-08-04T00:00:00Z"

输出:

{ "WindowExecutions": [ { "WindowId": "mw-ab12cd34eEXAMPLE", "WindowExecutionId": "6027b513-64fe-4cf0-be7d-1191aEXAMPLE", "Status": "IN_PROGRESS", "StartTime": "2021-08-04T11:00:00.000000-07:00" } ] }

有关更多信息,请参阅《S AWS ystems Manager 用户指南》中的 “查看有关任务和任务执行的信息 (AWS CLI)”。

PowerShell
用于 PowerShell

示例 1:此示例列出维护时段的所有执行。

Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d"

输出:

EndTime : 2/20/2017 6:30:17 PM StartTime : 2/20/2017 6:30:16 PM Status : FAILED StatusDetails : One or more tasks in the orchestration failed. WindowExecutionId : 6f3215cf-4101-4fa0-9b7b-9523269599c7 WindowId : mw-03eb9db42890fb82d

示例 2:此示例列出在指定日期之前的维护时段内的所有执行。

$option1 = @{Key="ExecutedBefore";Values=@("2016-11-04T05:00:00Z")} Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d" -Filter $option1

示例 3:此示例列出指定日期之后维护时段内的所有执行。

$option1 = @{Key="ExecutedAfter";Values=@("2016-11-04T05:00:00Z")} Get-SSMMaintenanceWindowExecutionList -WindowId "mw-03eb9db42890fb82d" -Filter $option1