DescribeMaintenanceWindowExecutions 搭配 CLI 使用 - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

DescribeMaintenanceWindowExecutions 搭配 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" } ] }

如需詳細資訊,請參閱 AWS Systems Manager 使用者指南中的檢視任務和任務執行的相關資訊 (AWS CLI)

PowerShell
for 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