Step 1: Download PowerShell for AWS from the link https://aws.amazon.com/powershell/
Step 2: Complete the installation
Step 3: Launch PowerShell ISE and run as administrator show below.
Step 4: Import AWS PowerShell module
Execute this command in PowerShell ISE to import the PowerShell cmdlets
Step 5: Start playing with AWS cmdlets
AWS has almost 3000 commands that can be used to automate and manage AWS infrastructure. Here is how you can find them.
$commands = Get-command –module AWSPowershell
Let’s try to use some of these cmdlets and see how we can make our administration in AWS a cake a walk.
Note: Please note that the idea of this blog is not to teach you all the cmdlets in powershell. The idea is to tell you how you can learn PowerShell for AWS all by yourself with no mentorship.
Alright let’s go for it. Now as we know that there are over 3K + cmdlets that can be used to manage our infra . Let’s try to search for some of these cmdlets . For example, some of the tasks that we do in our life as an AWS admin are as follows:
- Restarting / stopping / starting / terminating an instance
- Creating inventory of VM’s running across Geographical locations. (CIO Request J )
- S3 Bucket Metrics
- Sync to S3 Bucket ( scheduled )
These are just few of them which need very basic power shell skills.
How to search for a command
If there is need to “start “ or “ stop “ an instance , I would go and search for the right cmdlet from the 3000 + cmdlets and here is how we do it .
get-command "*start*instance*" -module awspowershell
C:\Users\hp> get-command "*start*instance*" -module awspowershell
CommandType Name Version S
----------- ---- ------- -
Cmdlet Restart-EC2Instance 188.8.131.52 A
Cmdlet Restart-LSInstance 184.108.40.206 A
Cmdlet Restart-OPSInstance 220.127.116.11 A
Cmdlet Restart-RDSDBInstance 18.104.22.168 A
Cmdlet Start-EC2Instance 22.214.171.124 A
Cmdlet Start-EC2InstanceMonitoring 126.96.36.199 A
Cmdlet Start-LSInstance 188.8.131.52 A
Cmdlet Start-OPSInstance 184.108.40.206 A
Cmdlet Start-RDSDBInstance 220.127.116.11 A
Now we have all the cmdlets that have the string “Start” and “instance” in it. It would be easy to find the command from this list rather than finding from 3000+ cmdlets.
Each cmdlet has help included as part of documentation. That means we can take a look at the examples and get hints from the documentation which is in built in power shell. To get the help and examples of a particular cmdlet, try this:
help start-instance -Examples
This gives extensive help documentation on start-instance cmdlet along with mostly used real life examples.