AWS

Use the AWS Tools for Windows PowerShell With Run Command – AWS Systems Manager

AWS System Manager is used to manage and operate resources on the cloud safely for the entire infrastructure. It offers the user to manage its working through a Run Command service using AWS Tools for PowerShell.

This guide will explain how to use AWS Tools for Windows PowerShell with the Run command.

Use the AWS Tools for Windows PowerShell with Run Command

Open the PowerShell from the system:

Explore the commands available for the AWS “System Manager” service:

Get-AWSCMdletName -Service Systems

 

Running the above command provide the list of commands which allows the user to communicate with the System Manager:

Get SSM Documents list in the table format by using this command:

Get-SSMDocumentList | Format-Table -AutoSize

 

Add a filter to the “Document Type” to only fetch records having “Command” as their value:

Get-SSMDocumentList -DocumentFilterList @{ Key = 'DocumentType'; Value = 'Command'} | Format-Table -AutoSize

 

Sort the list in alphabetical order with respect to the “Name” field:

Get-SSMDocumentList -DocumentFilterList @{ Key = 'DocumentType'; Value = 'Command'} | Sort-Object -Property Name| Format-Table -AutoSize

 

Get the contents for the “RunPowerShellScript” document in detail:

Get-SSMDocument -Name AWS-RunPowerShellScript

 

Build SSM run command containing comments and Document name with some parameters:

Send-SSMCommand -Comment 'Create some test Files' -DocumentName AWS-RunPowerShellScript -Target @{
    Key = 'tag:project'
    Values = 'AWSPowerShell'
} -Parameter @{
   commands = @(
        '$NewDir = "C:\Amazon"'
        '1..100 | % {Set-Content -Path "$NewDir\$PSItem.txt" -Value $PSItem}'
    )
}

 

To verify that the run command is executed or not, head into the “System Manager” service:

Locate the “Run Command” from the left panel and click on it:

Open the “Command history” section and find the executed command listed there:

This is all about using AWS tools for PowerShell with Run Command.

Conclusion

To use AWS Tools for Windows PowerShell with the Run command, open the PowerShell from the system. Get the list of all the commands used to communicate with the System Manager. Optimize the table to get a more specific list by using filters and sorting on the list. Use the list to find the command to be used with the Run command and verify it from the dashboard. This guide has explained the use of AWS Tools for Windows PowerShell with the Run command.

About the author

Talha Mahmood

As a technical author, I am eager to learn about writing and technology. I have a degree in computer science which gives me a deep understanding of technical concepts and the ability to communicate them to a variety of audiences effectively.