

• AWS Systems Manager CloudWatch 控制面板在 2026 年 4 月 30 日之后将不再可用。客户可以像现在一样继续使用 Amazon CloudWatch 控制台来查看、创建和管理其 Amazon CloudWatch 控制面板。有关更多信息，请参阅 [Amazon CloudWatch 控制面板文档](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：执行自动化文档**  
以下 `start-automation-execution` 示例运行自动化文档。  

```
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 用户指南》**中的[手动运行自动化工作流](https://docs.aws.amazon.com/systems-manager/latest/userguide/automation-working-executing-manually.html)。  
**示例 2：运行共享自动化文档**  
以下 `start-automation-execution` 示例运行一个共享的自动化文档。  

```
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 用户指南》**中的[使用共享 SSM 文档](https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-using-shared.html)。  
+  有关 API 详细信息，请参阅《AWS CLI Command Reference》**中的 [StartAutomationExecution](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ssm/start-automation-execution.html)。

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

**适用于 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 Reference（V4）》中的 [StartAutomationExecution](https://docs.aws.amazon.com/powershell/v4/reference)**。

**适用于 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 版本的详细信息。