Running a PowerShell script on a Turbot managed Windows Server

Turbot allows you to run custom powerhsell scripts with AWS Systems Manager. Turbot installs the SSM agents on every Windows instance you launch, if you have the proper policies enabled.

First thing to verify is that you have these Turbot Policies set to the following:

  • AWS > SSM > Enabled = Enabled
  • AWS > IAM > Turbot EC2 Instance Role = Enforce
  • AWS > EC2 > Instance Has Default EC2 Instance Profile Attached = Enforce
  • AWS > IAM > EC2 Role Has Turbot Default Instance Policies = Enforce
  • AWS > EC2 > Bootstrap Windows Instance = Enabled
  • Windows > Turbot User Password Rotation = Enforce: [x] days

So how can I run my custom powershell scripts with Systems Manger? You have 3 options, you can use the EC2 Console, use AWS Tools for Windows PowerShell or AWS CLI.

Send a Command Using the EC2 Console:

To execute a command using Run Command from the console

  • Open the Amazon EC2 console

  • In the navigation pane, choose Run Command.

  • Choose Run a command.

  • For the Command document, choose AWS-RunPowerShellScript for Windows instances.

  • For the Target instances, choose the instance you created. If you don't see the instance, verify that you are currently in the same region as the instance you created.

  • For Commands, this is where you will cut and paste in your powershell script.

  • (Optional) For Working Directory, specify a path to the folder on your EC2 instances where you want to run the command.

  • (Optional) For Execution Timeout, specify the number of seconds the EC2Config service or SSM agent will attempt to run the command before it times out and fails.

  • For Comment, we recommend providing information that will help you identify this command in your list of commands.

  • For Timeout (seconds), type the number of seconds that Run Command should attempt to reach an instance before it is considered unreachable and the command execution fails.

  • Choose Run to execute the command. Run Command displays a status screen. Choose View result.

  • To view the output, choose the Output tab, and then choose View Output to see the results of the script.

You also have the ability to run commands via AWS tools with Powershell, and using the AWS CLI. You can read more on those options here.

For more information, email

Was this article helpful?
0 out of 0 found this helpful