Getting started with AWS Tools for PowerShell

Windows IT professionals don’t have to start from scratch if they plan to use Amazon Web Services; their PowerShell knowledge can help them manage AWS offerings with a few lines of familiar code.

As more businesses look to AWS to run certain workloads, IT professionals have a few choices to manage and automate Amazon’s cloud services. You can administer the AWS environment via the web interface or the AWS command-line interface (CLI), but another option is the PowerShell module named AWS Tools for PowerShell.

Admins with working knowledge of Windows PowerShell can learn to use these new AWS cmdlets quickly by following these directions.

Create an AWS account to set up IAM keys

To start, log in to your existing account or create one at aws.amazon.com. AWS offers a free tier to learn how to use the cloud platform.

Next, create a user and generate keys with the Identity and Access Management (IAM) service in the AWS console. These keys authenticate and manage your AWS resources from PowerShell. For simplicity, I will create a user in the Administrators group that will have the keys to the castle. In production, you would never want to do this.

Using PowerShell to work with the Amazon Simple Storage Service.

Next, create a group with administrator access. Search for IAM in the AWS console, go the Groups tab and click Create New Group. Name the group whatever you like; I just use admin. Next, choose a policy to attach. The first policy, AdministratorAccess, is sufficient. Finally, create the group.

To create a user, go back to the initial IAM page and click Add user. Choose a name and access type. For the purposes of this article, I chose both programmatic access and the AWS Management console. Next, add the user to the administrative group you created. You should then be able to download a CSV file with the access key ID and access key.

Install AWS Tools for PowerShell

You can use AWS Tools for PowerShell anywhere you can install PowerShell: Mac, Linux and, of course, Windows.

Make sure you use the correct version; select the module for either the Windows PowerShell version or PowerShell Core. The name of the module differs. For Windows PowerShell, it is called AWSPowerShell, while the PowerShell Core version is AWSPowerShell.NetCore.

You can use AWS Tools for PowerShell anywhere you can install PowerShell: Mac, Linux and, of course, Windows.

I’m going to use the Windows PowerShell version. To install the module, you can use the MSI installer provided by AWS, install it from the PowerShell gallery or use Chocolatey.

To install it via PowerShell Gallery, use this command:

Install-Module awspowershell

If you would like to do it via Chocolatey, use this command instead:

choco install AWSTools.Powershell

Once the AWS Tools are installed, you may need to import the module.

Get-Module awspowershell | Import-Module

Finally, to finish the setup, set the profile to allow you to connect to AWS and run commands.

To stop an EC2 instance, use the cmdlet Stop-EC2Instance. In this example, I pipe the output of my previous command:

Get-EC2Instance -InstanceId ‘i-0fb1bc69ba6d4d745’ | Stop-EC2Instance

Managing S3 buckets

The cmdlets in the AWS Tools for PowerShell module give users a way to interact with Simple Storage Service (S3) buckets, objects, access control lists and policies. For AWS beginners, S3 is the AWS storage service.

In this scenario, I am going to view my current S3 buckets, upload an object into one bucket, copy an object from one bucket to another and then remove that object.

Are you sure you want to perform this action?Performing the operation “Remove-S3Object (DeleteObjects)” on target “”.[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is “Y”): a DeleteMarker DeleteMarkerVersionId Key VersionId———— ——————— — ———False test.txt

Since Microsoft Azure rivals AWS, it may be surprising to see how much you can manage in AWS with PowerShell. Jeffrey Snover, the creator of PowerShell, often mentions that the new goal of the scripting and automation tool is to manage anything with PowerShell, from any hypervisor to any cloud, such as Hyper-V, VMware, Azure or AWS.

Although the AWS CLI is a favorite among AWS engineers and administrators, the AWS Tools for PowerShell module offers a comprehensive method to manage cloud services from Amazon.