Step 1:-
Attach an IAM role with the AmazonEC2RoleforSSM managed policy to an Amazon EC2 instance.
Step 2 :-
If you are using IAM user account then Grant Your User Account Access to Systems Manager by attaching Policy AmazonSSMFullAccess to user account.
Step 3:-
Install the SSM Agent
The agent is installed by default on Windows AMIs starting in November 2016 and later, Amazon Linux AMIs starting with 2017.09, and all Amazon Linux 2 AMIs
Step 4:-
To execute a command using Run Command from the console
EC2 console --->> Run Command Tab
For Command document, choose AWS-RunPowerShellScript for Windows instances, and AWSRunShellScript for Linux instances.
Name : AWS-RunShellScript
For Target instances, choose the instance you created
For Commands, type Get-Service for Windows, or ps aux for Linux
Choose Run to execute the command. Run Command displays a status screen. Choose View result
Attach an IAM role with the AmazonEC2RoleforSSM managed policy to an Amazon EC2 instance.
Step 2 :-
If you are using IAM user account then Grant Your User Account Access to Systems Manager by attaching Policy AmazonSSMFullAccess to user account.
Step 3:-
Install the SSM Agent
The agent is installed by default on Windows AMIs starting in November 2016 and later, Amazon Linux AMIs starting with 2017.09, and all Amazon Linux 2 AMIs
Step 4:-
To execute a command using Run Command from the console
EC2 console --->> Run Command Tab
For Command document, choose AWS-RunPowerShellScript for Windows instances, and AWSRunShellScript for Linux instances.
Name : AWS-RunShellScript
For Target instances, choose the instance you created
For Commands, type Get-Service for Windows, or ps aux for Linux
Choose Run to execute the command. Run Command displays a status screen. Choose View result