Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅
中国的 Amazon Web Services 服务入门
(PDF)。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用指令文档版本运行命令
您可以使用文档版本参数指定在运行命令时使用 Amazon Systems Manager 文档的哪个版本。您可以为此参数指定以下选项之一:
运行以下过程,使用文档版本参数运行命令。
- Linux
-
在本地 Linux 计算机上使用 Amazon CLI 运行命令
安装并配置 Amazon Command Line Interface (Amazon CLI)(如果尚未执行该操作)。
有关信息,请参阅安装或更新 Amazon CLI 的最新版本。
-
列出所有可用文档
此命令将基于 Amazon Identity and Access Management (IAM) 权限列出您的账户可用的所有文档。
aws ssm list-documents
-
运行以下命令,查看文档的不同版本。将文档名称
替换为您自己的信息。
aws ssm list-document-versions \
--name "document name
"
-
运行以下命令,运行使用 SSM 文档版本的命令。将每个示例资源占位符
替换为您自己的信息。
aws ssm send-command \
--document-name "AWS-RunShellScript" \
--parameters commands="echo Hello" \
--instance-ids instance-ID
\
--document-version '$LATEST
'
- Windows
-
在本地 Windows 计算机上使用 Amazon CLI 运行命令
安装并配置 Amazon Command Line Interface (Amazon CLI)(如果尚未执行该操作)。
有关信息,请参阅安装或更新 Amazon CLI 的最新版本。
-
列出所有可用文档
此命令将基于 Amazon Identity and Access Management (IAM) 权限列出您的账户可用的所有文档。
aws ssm list-documents
-
运行以下命令,查看文档的不同版本。将文档名称
替换为您自己的信息。
aws ssm list-document-versions ^
--name "document name
"
-
运行以下命令,运行使用 SSM 文档版本的命令。将每个示例资源占位符
替换为您自己的信息。
aws ssm send-command ^
--document-name "AWS-RunShellScript" ^
--parameters commands="echo Hello" ^
--instance-ids instance-ID
^
--document-version "$LATEST
"
- PowerShell
-
要使用 Tools for PowerShell 运行命令,请执行以下步骤:
如果您尚未安装和配置 Amazon Tools for PowerShell(适用于 Windows PowerShell 的工具),请执行这些操作。
有关信息,请参阅安装 Amazon Tools for PowerShell。
-
列出所有可用文档
此命令将基于 Amazon Identity and Access Management (IAM) 权限列出您的账户可用的所有文档。
Get-SSMDocumentList
-
运行以下命令,查看文档的不同版本。将文档名称
替换为您自己的信息。
Get-SSMDocumentVersionList `
-Name "document name
"
-
运行以下命令,运行使用 SSM 文档版本的命令。将每个示例资源占位符
替换为您自己的信息。
Send-SSMCommand `
-DocumentName "AWS-RunShellScript" `
-Parameter @{commands = "echo helloWorld"} `
-InstanceIds "instance-ID
" `
-DocumentVersion $LATEST