I have this example from AWS sites:
Send-SSMCommand -DocumentName "AWS-RunPowerShellScript" -Parameter @{commands = "echo helloWorld"} -Target @{Key="instanceids";Values=@("i-0cb2b964d3e14fd9f")}
in which one line of PowerShell script (echo helloworld
) is being sent.
What if I have to send multiple line of PowerShell script through SSM. How to do that?
There are multiple ways you can achieve this. You can provide a script to run, which resides inside the instance. or you can create an array of commands - like this:
You can simply run multiple commands with ';' separator - like this:
Here is an example - you could run the script directly - which can have multiple lines:
You could also run the remote script with a custom document, which is either in s3 or github - find examples here: https://docs.aws.amazon.com/systems-manager/latest/userguide/integration-remote-scripts.html
I hope this helps.