

• 2026 年 4 月 30 日之後將不再提供 AWS Systems Manager CloudWatch Dashboard。客戶可以繼續使用 Amazon CloudWatch 主控台來檢視、建立和管理其 Amazon CloudWatch 儀表板，就像現在一樣。如需詳細資訊，請參閱 [Amazon CloudWatch Dashboard 文件](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)。

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

# 搭配使用 `StartAutomationExecution` 與 CLI
<a name="example_ssm_StartAutomationExecution_section"></a>

下列程式碼範例示範如何使用 `StartAutomationExecution`。

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

**AWS CLI**  
**範例 1：執行 Automation 文件**  
下列 `start-automation-execution` 範例示範執行 Automation 文件。  

```
aws ssm start-automation-execution \
    --document-name {{"AWS-UpdateLinuxAmi"}} \
    --parameters {{"AutomationAssumeRole=arn:aws:iam::123456789012:role/SSMAutomationRole,SourceAmiId=ami-EXAMPLE,IamInstanceProfileName=EC2InstanceRole"}}
```
輸出：  

```
{
  "AutomationExecutionId": "4105a4fc-f944-11e6-9d32-0a1b2EXAMPLE"
}
```
如需詳細資訊，請參閱《AWS Systems Manager 使用者指南》**中的 [Running an Automation Workflow Manually](https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-working-executing-manually.html)。  
**範例 2：執行共用 Automation 文件**  
下列 `start-automation-execution` 範例示範執行共用的 Automation 文件。  

```
aws ssm start-automation-execution \
    --document-name {{"arn:aws:ssm:us-east-1:123456789012:document/ExampleDocument"}}
```
輸出：  

```
{
  "AutomationExecutionId": "4105a4fc-f944-11e6-9d32-0a1b2EXAMPLE"
}
```
如需詳細資訊，請參閱《AWS Systems Manager 使用者指南》**中的 [Using shared SSM documents](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-using-shared.html)。  
+  如需 API 詳細資訊，請參閱《AWS CLI 命令參考》**中的 [StartAutomationExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/start-automation-execution.html)。

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

**Tools for PowerShell V4**  
**範例 1：此範例示範執行指定自動化角色、AMI 來源 ID 和 Amazon EC2 執行個體角色的文件。**  

```
Start-SSMAutomationExecution -DocumentName AWS-UpdateLinuxAmi -Parameter @{'AutomationAssumeRole'='arn:aws:iam::123456789012:role/SSMAutomationRole';'SourceAmiId'='ami-f173cc91';'InstanceIamRole'='EC2InstanceRole'}
```
**輸出：**  

```
3a532a4f-0382-11e7-9df7-6f11185f6dd1
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V4)》**中的 [StartAutomationExecution](https://docs.aws.amazon.com/powershell/v4/reference)。

**Tools for PowerShell V5**  
**範例 1：此範例示範執行指定自動化角色、AMI 來源 ID 和 Amazon EC2 執行個體角色的文件。**  

```
Start-SSMAutomationExecution -DocumentName AWS-UpdateLinuxAmi -Parameter @{'AutomationAssumeRole'='arn:aws:iam::123456789012:role/SSMAutomationRole';'SourceAmiId'='ami-f173cc91';'InstanceIamRole'='EC2InstanceRole'}
```
**輸出：**  

```
3a532a4f-0382-11e7-9df7-6f11185f6dd1
```
+  如需 API 詳細資訊，請參閱《AWS Tools for PowerShell Cmdlet 參考 (V5)》**中的 [StartAutomationExecution](https://docs.aws.amazon.com/powershell/v5/reference)。

------

如需 AWS SDK 開發人員指南和程式碼範例的完整清單，請參閱 [搭配 AWS SDK 使用此服務](sdk-general-information-section.md)。此主題也包含有關入門的資訊和舊版 SDK 的詳細資訊。