Using AWS with Windows PowerShell

ethanmillar
Senior ASP.Net Developer
Aegis Soft Tech
Blogger
Share this content
0

In this blog post, asp.net mvc developers will talk about the tools of Windows PowerShell that are used with AWS by professionals in order to handle their services. You will learn how they use AWS with Windows PowerShell.

The Windows PowerShell tools for AWS allow the administrators and developers to manage their services from the scripting environment of Windows PowerShell.  It is possible to manage the AWS resources using the tools of Windows PowerShell that are used for managing the Windows environment.

Microsoft powershell

PREREQUISITES:

For using the Windows PowerShell Tools or the tools for the PowerShell Core, there should be an AWS account.
In order to use the Windows PowerShell tools for AWS, the following conditions should be satisfied:

  1. Windows XP of Microsoft or later.
  2. PowerShell 2.0 or above.

The Windows Server version 2008 R2 and the Windows 7 comes with the installation of Windows PowerShell 2.0. Windows Server 2012 and Windows 8 come with the installation of PowerShell 3.0.

INSTALLTION OF WINDOWS POWERSHELL TOOLS:

The Windows PowerShell tools for AWS are one of the components that can be installed by running the tools for the installer .msi for Windows.

The Windows PowerShell tools installer will install the latest version AWS SDK of Asp.Net. If the Visual Studio is installed, the AWS Visual Studio Toolkit can be installed by the installer.

All the Windows AMIs (Amazon Machine Images) has AWS Tools pre-installed for the Windows PowerShell. As an example, for using PowerShell tools on Amazon EC2 objects, the sample of AWS EC2 can be viewed from Visual Studio by clicking on the following:

New Project->AWS->Compute and Networking->EC2 Sample of AWS

INSTALLATION OF THE AWS TOOLS:

It is possible to install the PowerShell Core Tools of AWS on systems that run Microsoft PowerShell version 5.1 or later. Following operating systems support the PowerShell Core Tools for AWS.

  1. Windows 10.
  2. Mac OS X
  3. Windows Enterprise 8.1
  4. Windows Server R2 2012
  5. Ubuntu 14.04 or later
  6. CentOS Linux 7

Once the PowerShell 5.1 is installed on the system, the PowerShell Core tools for AWS can be found on the website of PowerShell Gallery.

ENABLE The EXECUTION OF SCRIPT:

For loading the AWS tools for the module of the Windows PowerShell, the PowerShell script execution should be enabled if it is not done already. For enabling the execution of script, execute the Set-ExecutionPolicy cmdlet for setting a policy to RemoteSigned. By default, policy of Restricted is used by the Windows PowerShell.

To enable the Execution of Script:

  1. It is required to have the Administrator rights for setting the execution policy. In case, you are not logged in as a user having admin rights, open the session of PowerShell as Administrator. Select start, then all programs, then go to Accessories and click on Windows PowerShell. Right-click on the Windows PowerShell and select Run as Administrator option.
  2. Write the following in command prompt:
    Set-ExecutionPolicy RemoteSigned

The Windows PowerShell Tools installer will update the path of Module to include the path of directory containing the AWS PowerShell module. In case, a user is running the PowerShell 3.0, the module of AWSPowerShell is automatically loaded when one of the AWS cmdlets is run. It allows the use of AWS cmdlets more interactively, even in case the execution policy of the system is set to disallow the execution of script.

CONFIGURE POWERSHELL CONSOLE FOR USING AWS POWERSHELL TOOLS:

A group for start menu is created by the installer known as the Amazon Web Services containing a shortcut known as Windows PowerShell for AWS. The AWSPowerShell module will be automaticallyimported and then execute the Initialize-AWSDefaults cmdlet.

Some additional software is created by the installer known as AWS Tools of Windows, which creates a visual display of the AWS resources for developers.

LOADING OF AWS TOOLS FOR POWERSHELL MODULE:

Perform the following steps to load the module of PowerShell Tools in current session:

  1. Open the prompt of PowerShell and run the command as shown:
    PS C :\> Import-Module AWSPowerShell
  2. In order to verify that module is correctly loaded, run the below command:
    PS C :\> Get-Module

If the list contains the entry of AWSPowerShell, it indicates the tools for the module of Windows PowerShell were loaded successfully.

LOADING AWS CLI IN EVERY SESSION FOR POWERSHELL MODULE:

In order to load the module of AWSPowerShell automatically every time a session is started, add the same to the profile of PowerShell. However, by adding the commands to PowerShell profile can slow the starting speed of the PowerShell session.

The $profile variable of the PowerShell contains full path of the text file containing the PowerShell profile. This variable is not an environment variable of Windows; it is present only in the PowerShell session. Run echo in order to view its value. Any text editor can be used to edit this file.

There might be a need to create both the profile and the profile directory in case they do not exist.

UPDATE WINDOWS POWERSHELL TOOLS AND POWERSHELL CORE TOOLS FOR AWS:

The update versions of Windows PowerShell tools and PowerShell core tools for AWS are released periodically.  It will be required to update the versions running locally. In order to determine the current running version, execute the Get-AWSPowerShellVersion cmdlet and compare the same with the version available the AWS Tools of Windows PowerShell or the PowerShell gallery.   It is recommended to check the updated versions of AWS PowerShell Tools after every three weeks of time.

Update the Windows PowerShell installed tools by downloading the latest version of MSI package and comparing the MSI file name with the number that is obtained from the Get-AWSPowerShellVersion cmdlet.

You must follow each and every step shared by asp.net MVC developers to make best use of AWS with Windows PowerShell. If there is anything left unclear, ask in comments below. The professionals will reply to your question soon.

Replies

Please login or register to join the discussion.

There are currently no replies, be the first to post a reply.