繁体   English   中英

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

[英]How do I properly reference a Powershell script from an AWS SSM document?

runPowerShellScript API调用的Amazon EC2简单系统管理器文档显示了如何指定执行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

正确的语法是什么?

适用于RunCommand参数的AWS文档指出:

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

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

解决方法是仅在runCommand参数中使用脚本名称,并在WorkingDirectory中指定完整路径。

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

这种格式将使ssm create-document命令成功运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM