AWS Tools for Windows PowerShell
User Guide (Version 1.0)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Did this page help you?  Yes | No |  Tell us about it...

Setting up the AWS Tools for Windows PowerShell

Setting up the AWS Tools for Windows PowerShell

Prerequisites

To use the AWS Tools for Windows PowerShell, you must have an AWS account. If you do not yet have an AWS account, see AWS Account and Access Keys for instructions on how to sign up.

To use the AWS Tools for Windows PowerShell, your installed system must meet the following prerequisites:

  • Microsoft Windows XP or later

  • Windows PowerShell 2.0 or later

Windows 7 and Windows Server 2008 R2 come with Windows PowerShell 2.0 installed. Windows 8 and Windows Server 2012 come with Windows PowerShell 3.0 installed. For earlier versions of Windows, such as Windows XP, Windows Vista, Windows Server 2003, and Windows Server 2008, you can get PowerShell 2.0 by installing the Windows Management Framework

Download and Install the AWS Tools for Windows PowerShell

The AWS Tools for Windows PowerShell is one of the optional components that you can install using the AWS Tools for Windows installer .msi. Download the installer by navigating to the following URL and clicking AWS Tools for Windows.

http://aws.amazon.com/powershell/

The installer for the PowerShell Tools installs the most recent version of the AWS SDK for .NET. If you have Microsoft Visual Studio installed, the installer can also install the AWS Toolkit for Visual Studio.

All Windows Amazon Machine Images (AMIs) have the AWS Tools for Windows PowerShell pre-installed. For an example of using the PowerShell Tools on an Amazon EC2 instance, see the following sample in the AWS SDK for .NET.

 New | Project... | AWS | Compute and Networking | AWS EC2 Sample

Enable Script Execution

In order to load the AWS Tools for Windows PowerShell module, you need to enable PowerShell script execution—if you have not already done so. To enable script execution, use the Set-ExecutionPolicy cmdlet to set a policy of RemoteSigned. By default, PowerShell uses a policy of Restricted. For more information about execution policies, see Microsoft's TechNet documentation.

To enable script execution

  1. Administrator privileges are required to set the execution policy. If you are not logged in as a user with administrator privileges, you need to open a PowerShell prompt as Administrator: Click Start and then click All Programs; click Accessories, and then click Windows PowerShell; now right-click Windows PowerShell, and select Run as administrator from the context menu.

  2. At the command prompt, type: Set-ExecutionPolicy RemoteSigned

Note

On a 64-bit system, you will also need to perform these steps for the 32-bit version of PowerShell, Windows PowerShell (x86).

If you do not have the execution policy set correctly, PowerShell generates the following message.

File C:\Users\teslan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because the execution
 of scripts is disabled on this system. Please see "get-help about_signing" for more details.
At line:1 char:2
+ . <<<<  'C:\Users\teslan\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'
    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException
    + FullyQualifiedErrorId : RuntimeException 

The installer for the PowerShell Tools updates the PSModulePath to include the location of the directory that contains the AWSPowerShell module. As a result, if you are using PowerShell version 3, the AWSPowerShell module is loaded automatically whenever you run one of the AWS cmdlets. This enables you to use the AWS cmdlets interactively even if the execution policy on your system is set to disallow script execution.

Because the PSModulePath includes the location of the AWS module's directory, the Get-Module -ListAvailable cmdlet shows the module.

PS C:\> Get-Module -ListAvailable

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Manifest   AppLocker                 {}
Manifest   BitsTransfer              {}
Manifest   PSDiagnostics             {}
Manifest   TroubleshootingPack       {}
Manifest   AWSPowerShell             {Update-EBApplicationVersion, Set-DPStatus, Remove-IAMGroupPol...

Configure a PowerShell Console to Use the AWS Tools for Windows PowerShell

The installer creates a Start Menu group called, Amazon Web Services, which contains a shortcut called Windows PowerShell for AWS. For PowerShell version 2, this shortcut automatically imports the AWSPowerShell module and then runs the Initialize-AWSDefaults cmdlet. For PowerShell version 3, the AWSPowerShell module is loaded automatically whenever you run an AWS cmdlet. So, for PowerShell version 3 installations, the shortcut created by the installer only runs the Initialize-AWSDefaults cmdlet. For more information about Initialize-AWSDefaults, see Using AWS Credentials.

The installer also creates an additional shortcut called AWS Tools for Windows, which opens a visual display of AWS resources for Windows developers.

If you use PowerShell version 3 or if you only use the shortcut installed by the installer, you do not need to configure a PowerShell window to use the AWS Tools for Windows PowerShell. However, if, for example, you use PowerShell version 2 with a specially configured PowerShell window and want to add support for the tools, you need to load the AWS module yourself.

How to Load the AWS Tools for Windows PowerShell Module (PowerShell version 2)

To load the PowerShell Tools module into your current session

  1. Open a PowerShell prompt and type the following command:

    PS C:> import-module "C:\Program Files (x86)\AWS Tools\PowerShell\AWSPowerShell\AWSPowerShell.psd1"
  2. To verify that the module was loaded, type the following command:

    PS C:> Get-Module

    If you see an entry in the list named AWSPowerShell (see the following), then the PowerShell Tools module was loaded successfully.

    ModuleType Name                      ExportedCommands
      ---------- ----                      ----------------
      Binary     AWSPowerShell             {Update-EBApplicationVersion, Set-S3ACL...

Load AWS CLI for PowerShell Module into Every Session (PowerShell version 2)

To automatically load the AWSPowerShell module every time you start a PowerShell session, you can add it to your PowerShell profile. Note, however, that adding commands to your PowerShell profile can slow down the speed at which a PowerShell session starts up.

The PowerShell $profile variable contains the full path to the text file that contains your PowerShell profile. This variable is available only in a PowerShell session; it is not one of the regular Windows environment variables. To view the value of this variable, use echo.

echo $profile
C:\Users\kncubq\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

You can edit this file with any text editor, such as notepad.exe.

notepad $profile

You may need to create both the profile directory and the profile itself if they do not already exist.

Versioning

New versions of the PowerShell Tools will release periodically to support new AWS services and features. To tell what version of the tools you have installed, use the following command:

PS C:\> Get-AWSPowerShellVersion
AWS Tools for Windows PowerShell
Version 1.0.0.9
Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Version 1.5.9.1
Copyright 2009-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html] 

You can also specify the -ListServices option to see a list of which AWS services are supported in the current version of the tools.

PS C:\> Get-AWSPowerShellVersion -ListServices
AWS Tools for Windows PowerShell
Version 1.0.0.9
Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Amazon Web Services SDK for .NET
Version 1.5.9.1
Copyright 2009-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.

This software includes third party software subject to the following copyrights:
- Logging from log4net, Apache License
[http://logging.apache.org/log4net/license.html]

Service                                 Noun Prefix          Version
-------                                 -----------          -------
Auto Scaling                            AS                   2011-01-01
Amazon CloudFront                       CF                   2012-07-01
AWS CloudFormation                      CFN                  2010-05-15
Amazon CloudSearch                      CS                   2011-02-01
Amazon CloudWatch                       CW                   2010-08-01
Amazon ElastiCache                      EC                   2012-03-09
Amazon Elastic Compute Cloud            EC2                  2012-10-01
Elastic Load Balancing                  ELB                  2012-06-01
Amazon Elastic MapReduce                EMR                  2009-03-31
AWS Identity and Access Management      IAM                  2010-05-08
AWS Import/Export                       IE                   2010-06-01
AWS Route 53                            R53                  2012-02-29
Amazon Relational Database Service      RDS                  2012-09-17
Amazon Simple Storage Service           S3                   2006-03-01
Amazon Simple Email Service             SES                  2010-12-01
AWS Storage Gateway                     SG                   2012-06-30
Amazon Simple Notification Service      SNS                  2010-03-31
Amazon Simple Queue Service             SQS                  2012-11-05
AWS Security Token Service              STS                  2011-06-15