如何从AWS SSM文档正确引用Powershell脚本?

时间:2015-12-09 18:54:41

标签: amazon-web-services aws-cli

Amazon EC2 Simple Systems Manager documentation for the runPowerShellScript API调用显示如何指定PowerShell脚本的执行路径。

我试图指定完整的脚本路径,如文档中所示:

"runCommand":"c:\tools\GetTools.ps1",

但是在创建文档时出现语法错误,即使JSON文档是正确的:

aws ssm create-document --content file://myssmdocument.json --name "runPSScript"

A client error (InvalidDocumentContent) occurred when calling the CreateDocument operation: JSON not well-formed. at Line: 12, Column: 29

正确的语法是什么?

1 个答案:

答案 0 :(得分:1)

RunCommand 参数的AWS文档声明:

"指定要运行的命令或实例上现有脚本的路径。"

看来参数实际上并不接受路径。如果您提供错误,它将产生如上所述的错误。

解决方法是仅使用 runCommand 参数中的脚本名称,并在 WorkingDirectory

中指定完整路径
      "runCommand":"GetTools.ps1",
      "workingDirectory": "c:\tools"

此格式将允许 ssm create-document 命令成功运行。