简体   繁体   中英

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.

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:

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:

"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":"GetTools.ps1",
      "workingDirectory": "c:\tools"

This format will allow the ssm create-document command to run successfully.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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