Troubleshooting AWS EC2 Instance for PowerShell Script Execution

AWS EC2 Troubleshooting: PowerShell Script Execution

Prev Question Next Question

Question

You have deployed a Windows Server instance (x86_64) in AWS EC2

After the instance has run for a week, you realized that you needed to run a script in PowerShell.

You were logged in the AWS EC2 console and started using Systems Manager to run a command.

You chose the command as "AWS-RunPowerShellScript"

However, your instance cannot be selected as the target.

How should you troubleshoot the issue so that the command can run in the current Windows instance successfully? (Select TWO.)

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

Correct Answer - C, E.

AWS Systems Manager Run Command is a service to run a command for Windows or Linux instance:

However, if the instance cannot be seen as the target for the command to run, some items must be checked according to https://docs.aws.amazon.com/systems-manager/latest/userguide/troubleshooting-remote-commands.html?icmpid=docs_ec2_console.

Option A is incorrect: Because “AWS-RunPowerShellScript” is correct while “AWS-RunShellScript” is for Linux instance.

Option B is incorrect: Because the Windows instance is supported.

Check https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-prereqs.html for the supported Operating Systems.

Option C is CORRECT: Because only Amazon EC2 Windows Amazon Machine Images (AMIs) and certain Linux AMIs are pre-configured with the SSM Agent.

You need to check if the SSM Agent is properly installed.

Option D is incorrect: Because system patches do not impact the SSM connection.

Option E is CORRECT: Because a proper IAM instance role is required; otherwise, EC2 cannot communicate with SSM API.

Commands > Run a command

Run a command

Acommand document includes the information about the command you want to run. Select a command document from the following list and then specify parameters for the command.

Command document* @

Owned by Me or Amazon v Q Filter by attributes

Name Owner Platform type
AWS-InstallSpecificWindowsUpdates Amazon Windows
AWS-RunShellScript Amazon Linux
AWS-ConfigureCloudWatch Amazon Windows

e@ AWS-RunPowerShellScript Amazon Windows, Linux
AWS-ApplyPatchBaseline Amazon Windows
AWS-UpdateEC2Config Amazon Windows

AWS.InctallWindowel Indatec Amazon Windowe

The scenario presented describes an issue where the user cannot select their Windows Server instance as a target to run a PowerShell script using Systems Manager's "AWS-RunPowerShellScript" command. To troubleshoot the issue, the following steps can be taken:

  1. Verify that the instance is a Windows Server instance (x86_64) - This is important to ensure that the correct type of instance is being targeted. If the instance is not a Windows Server instance, then the "AWS-RunPowerShellScript" command will not work.

  2. Check if the instance is running - It is important to ensure that the instance is running before trying to run any commands on it. If the instance is not running, start it before proceeding.

  3. Check if the latest version of SSM (AWS Systems Manager) Agent is installed on the Windows instance - AWS Systems Manager agent must be installed on the instance to enable communication with the Systems Manager service. The agent must be running, and its version must be compatible with the Systems Manager version in use.

  4. Check if the Windows instance has the latest system patches installed - Before attempting to run any scripts, it is essential to ensure that the instance is up-to-date with the latest system patches. This will help prevent any compatibility issues that may arise due to outdated patches.

  5. Verify that the instance has configured with the IAM role that enables it to communicate with the Systems Manager API - An IAM role is required to enable communication between the instance and Systems Manager API. Ensure that the instance has been configured with the appropriate IAM role that grants it the required permissions to use the "AWS-RunPowerShellScript" command.

Based on the above steps, the following options can be eliminated:

Option B is incorrect because Systems Manager supports both Linux and Windows instances, so the Windows instance should be available as a target.

Option A is incorrect because "AWS-RunShellScript" is used to run shell scripts on Linux instances, and not PowerShell scripts on Windows instances.

Therefore, the correct answers are C and D. By ensuring that the SSM agent is up-to-date and that the instance has the latest system patches installed, any compatibility issues with the Systems Manager service should be resolved.