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

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

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

GetMaintenanceWindowExecutionTask 搭配 CLI 使用

下列程式碼範例示範如何使用 GetMaintenanceWindowExecutionTask

CLI
AWS CLI

取得維護時段任務執行的相關資訊

下列get-maintenance-window-execution-task範例會列出屬於指定維護時段執行一部分的任務相關資訊。

aws ssm get-maintenance-window-execution-task \ --window-execution-id "518d5565-5969-4cca-8f0e-da3b2EXAMPLE" \ --task-id "ac0c6ae1-daa3-4a89-832e-d3845EXAMPLE"

輸出:

{ "WindowExecutionId": "518d5565-5969-4cca-8f0e-da3b2EXAMPLE", "TaskExecutionId": "ac0c6ae1-daa3-4a89-832e-d3845EXAMPLE", "TaskArn": "AWS-RunPatchBaseline", "ServiceRole": "arn:aws:iam::111222333444:role/aws-service-role/ssm.amazonaws.com/AWSServiceRoleForAmazonSSM", "Type": "RUN_COMMAND", "TaskParameters": [ { "BaselineOverride": { "Values": [ "" ] }, "InstallOverrideList": { "Values": [ "" ] }, "Operation": { "Values": [ "Scan" ] }, "RebootOption": { "Values": [ "RebootIfNeeded" ] }, "SnapshotId": { "Values": [ "{{ aws:ORCHESTRATION_ID }}" ] }, "aws:InstanceId": { "Values": [ "i-02573cafcfEXAMPLE", "i-0471e04240EXAMPLE", "i-07782c72faEXAMPLE" ] } } ], "Priority": 1, "MaxConcurrency": "1", "MaxErrors": "3", "Status": "SUCCESS", "StartTime": "2021-08-04T11:45:35.088000-07:00", "EndTime": "2021-08-04T11:53:09.079000-07:00" }

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

PowerShell
for PowerShell 工具

範例 1:此範例列出屬於維護時段執行一部分的任務相關資訊。

Get-SSMMaintenanceWindowExecutionTask -TaskId "ac0c6ae1-daa3-4a89-832e-d384503b6586" -WindowExecutionId "518d5565-5969-4cca-8f0e-da3b2a638355"

輸出:

EndTime : 2/21/2017 4:00:35 PM MaxConcurrency : 1 MaxErrors : 1 Priority : 10 ServiceRole : arn:aws:iam::123456789012:role/MaintenanceWindowsRole StartTime : 2/21/2017 4:00:34 PM Status : FAILED StatusDetails : The maximum error count was exceeded. TaskArn : AWS-RunShellScript TaskExecutionId : ac0c6ae1-daa3-4a89-832e-d384503b6586 TaskParameters : {Amazon.Runtime.Internal.Util.AlwaysSendDictionary`2[System.String,Amazon.SimpleSystemsManagement.Model.MaintenanceWindowTaskPara meterValueExpression]} Type : RUN_COMMAND WindowExecutionId : 518d5565-5969-4cca-8f0e-da3b2a638355