Quantcast
Channel: Active questions tagged amazon-ec2 - Stack Overflow
Viewing all articles
Browse latest Browse all 29245

AWS CLI AWS-RunRemoteScript from Powershell with parameters returns an error when commandline contains space

$
0
0

my goal is to automate some AWS process using the PowerShell.

One of the steps is to execute the ps1 script on the EC2 Windows machine from the remote location (S3 in my case).

The problem is that the script has to be run with mandatory parameters. The CLI throws whenever the command contains a space:

aws ssm send-command --region us-west-2 --targets Key=tag:T,Values=V --document-name "AWS-RunRemoteScript" --parameters '{\"sourceType\":[\"S3\"],\"sourceInfo\":[\"{\\\"path\\\":\\\"https://bucketName.s3-us-west-2.amazonaws.com/folder/Install.ps1\\\"}\"],\"commandLine\":[\".\\Install.ps1 -Param1 value\"]}'

returns

aws : usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
At line:1 char:1
+ aws ssm send-command --region us-west-2 --targets Key=tag:T,Values=V  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (usage: aws [opt....] [parameters]:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

To see help text, you can run:
  aws help
  aws <command> help
  aws <command> <subcommand> help
Unknown options: -Param1, value"]}

while without the -Param1 value works fine. Even adding a space at the end of the "commandLine" leads to the problem

... \"commandLine\":[\".\\Install.ps1 \"]}' results with ... Unknown options: "]}

I suspect it's some kind of PowerShell syntax/escaping issue because the same command (with proper escaping) works on bash console.

Referring to the official documentation it should work on bash shell, but I couldn't find any working example from powershell....


Viewing all articles
Browse latest Browse all 29245

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>