How-To
How to Update the AWS Tools for PowerShell
Unlike Amazon's web interface, AWS does not automatically update command-line tools such as the AWS Tools for PowerShell.
If you work with AWS long enough it is inevitable that you will occasionally have to delve into the command-line interface. While there is nothing wrong with relying almost exclusively on the GUI-based management tools, there is at least one problem associated with a CLI environment that is seldom used.
Unlike Amazon's web interface, AWS does not automatically update command-line tools such as the AWS Tools for PowerShell. If you seldom work from the command line, you may one day discover that the command-line environment that installed on your computer lacks the ability to manage newer AWS features and services. Fortunately, there is a way to update the AWS Tools for PowerShell.
Before you attempt to update the AWS Tools for PowerShell, I recommend checking to see what version you currently have installed. To do so, open the AWS Tools for PowerShell and then enter the following command:
Get-AWSPowerShellVersion
You can see an example of how this command works in Figure 1. As you can see in the figure, this PowerShell for AWS deployment is currently running version 4.0.5.0, which dates all the way back to 2020.
It is worth noting that you can gather a bit more information from this PowerShell cmdlet. As previously mentioned, once installed, the AWS Tools for PowerShell are static, meaning that they are not automatically updated to support new services. If you want to see the services that your AWS Tools for PowerShell deployment supports then you can get that information by entering the following command:
Get-AWSPowerShellVersion -ListServiceVersionInfo
If you look at Figure 2 for example, you will notice that my currently installed AWS Tools for PowerShell version does not support the AWS Cloud Map service because Cloud Map was introduced long after this particular version of the AWS Tools for PowerShell was created.
As you look at the figure above, you will notice that there is a bit more information that is displayed. For each supported service, you can see a noun prefix and an SDK assembly version. The SDK assembly version is just that -- it's the version number that is associated with the SDK used to support that particular service. The noun prefix is essentially just an abbreviation that can take the place of a service name.
To give you a more concrete example, the noun prefix for the Amazon Elastic Compute Cloud (EC2) service is simply EC2. PowerShell cmdlets, as I'm sure you know, as made of verb-noun pairs. Therefore all of the EC2-related PowerShell cmdlets use EC2 as the first few characters of the noun portion of the cmdlet. Some of these cmdlets, for example, include: New-EC2instance, Get-EC2Image, New-EC2SecurityGroup and Get-EC2KeyPair. Each of these cmdlets includes the letters EC2 as a prefix for the noun portion of the cmdlet.
So now that I have shown you how to retrieve AWS Tools for PowerShell version information and how to gather information about supported services, I want to turn my attention to the actual upgrade process, which requires you to use an elevated PowerShell session.
According to AWS documentation, the command used for updating the AWS Tools for PowerShell module is:
Update-AWSToolsModule -CleanUp
However, this is where the whole concept of versioning comes into play. If you look at the command syntax documentation, it indicates that the Update-AWSToolsModule cmdlet was not introduced until version 4.1.176.0 of the tools. If you are running a version older than that then this command does not exist.
In such a situation, your best option is to manually install the required module and then check to see if any updates are available. To do so, run this command:
Install-Module -Name AWSPowerShell -RequiredVersion 4.1.176 -SkipPublisherCheck
You can see what this command looks like in Figure 3.
In case you are wondering, this cmdlet downloads the latest version of the tools from the PSGallery repository. The Cleanup portion of the command tells Windows to remove the old versions.
You can also update the AWS Tools for PowerShell on systems running PowerShell core. PowerShell Core is the cross platform version of PowerShell that runs on Windows, Linux, and MacOS. To do so however, you will need to uninstall and then reinstall the tools. The commands used for doing so are:
Uninstall-Module -Name AWSPowerShell.NetCore -AllVersions
Install-Module -Name AWSPowerShell.NetCore
About the Author
Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.