[英]How do I properly reference a Powershell script from an AWS SSM document?
The Amazon EC2 Simple Systems Manager documentation for the runPowerShellScript API call show how to specify a path to a PowerShell script for execution. runPowerShellScript API调用的Amazon EC2简单系统管理器文档显示了如何指定执行PowerShell脚本的路径。
I have tried to specify the full script path as indicated in the documentation: 我试图按照文档中的说明指定完整的脚本路径:
"runCommand":"c:\tools\GetTools.ps1",
but I get a syntax error when creating the document, even though the JSON document is correct: 但是即使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
What is the correct syntax? 正确的语法是什么?
The AWS documentation for the RunCommand parameter states: 适用于RunCommand参数的AWS文档指出:
"Specify the command to run or the path to an existing script on the instance." “指定要运行的命令或实例上现有脚本的路径。”
It appears the parameter does not actually accept a path. 看来参数实际上不接受路径。 It will generate an error as above if you provide one.
如果您提供一个,它将产生如上所述的错误。
The work around is to use only the script name in the runCommand parameter, and specify the full path in the WorkingDirectory 解决方法是仅在runCommand参数中使用脚本名称,并在WorkingDirectory中指定完整路径。
"runCommand":"GetTools.ps1",
"workingDirectory": "c:\tools"
This format will allow the ssm create-document command to run successfully. 这种格式将使ssm create-document命令成功运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.