AWS Developer Tools Blog
Announcing Support for the PowerShell Gallery
The AWS Tools for Windows PowerShell have until now been made available in a single MSI installer that also contains the AWS SDK for .NET and AWS Toolkit for Visual Studio. MSIs have historically been the primary method of installing software on Windows. On the Linux and OS X platforms, package managers have become the primary mechanism for distributing and acquiring software, with package mangers like apt-get, yum, npm and pip providing simple experiences to install software from large repositories of packages. The Windows ecosystem has several package managers, Nuget targeted at developers and Chocolately for general purpose software.
We’re pleased to announce that you can now obtain the AWSPowerShell module from the new PowerShell Gallery (https://www.powershellgallery.com/packages/AWSPowerShell/). The PowerShell Gallery is a Microsoft repository for the new PowerShell package management system. This post explains how to get started using the Gallery to install and update the tools.
Gallery Requirements
As noted on the PowerShell Gallery homepage, to use the Gallery the Microsoft Windows Management Framework (WMF) v5 preview is required. Follow the link to obtain and install the preview if needed for your system.
Installing the AWSPowerShell Module
Once you have installed the WMF version 5 preview, you can run the Get-PSRepository
cmdlet to see details of the Gallery setup:
PS C:> Get-PSRepository
Name OneGetProvider InstallationPolicy SourceLocation
---- -------------- ------------------ --------------
PSGallery NuGet Untrusted https://...
You install the module by using the Install-Module
cmdlet. To install the AWSPowerShell tools (you may want to consider adding the -Verbose
switch to see additional progress information from the install cmdlet):
PS C:> Install-Module -Name AWSPowerShell
If you already have the AWSPowerShell module installed from earlier use of our MSI installer, Install-Module
will exit with a message similar to this:
PS C:> Install-Module -Name AWSPowerShell
WARNING: Version '2.3.31.0' of module 'AWSPowerShell' is already installed at 'C:Program Files (x86)AWS ToolsPowerShellAWSPowerShell'.
To delete version '2.3.31.0' and install version '2.3.35.0', run Install-Module, and add the -Force parameter.
PS C:>
To force the install to occur, re-run the command as suggested in the message:
PS C:> Install-Module -Name AWSPowerShell -Force -Verbose
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: The specified module will be installed in 'C:Program FilesWindowsPowerShellModules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'AWSPowerShell' with version '2.3.35.0' from the repository
'https://www.powershellgallery.com/api/v2/'.
VERBOSE: NuGet: Installing 'AWSPowerShell 2.3.35.0'.
VERBOSE: NuGet: Successfully installed 'AWSPowerShell 2.3.35.0'.
VERBOSE: Module 'AWSPowerShell' was installed successfully.
PS C:>
Install-Module
will not in this case actually uninstall the previous version. As explained later in this blog post, the default ordering of search paths for modules means that the newer version installed from the Gallery will take precedence—this is useful if you are running the tools on an EC2 instance (although remember that to use the Gallery, you need to install the WMF version 5 preview first). Once you close and open a new shell console, the new version will be running, which you can verify by running Get-AWSPowerShellVersion
.
Where is the Module Installed?
The default install location used by Install-Module
is ”C:Program FilesWindowsPowerShellModules” It’s also possible to have Install-Module
install the tools to your local profile folder (”C:UsersuseridDocumentsWindowsPowerShellModules”) using the -Scope
parameter:
PS C:> Install-Module -Name AWSPowerShell -Scope CurrentUser
The default value for -Scope
if the parameter is not specified is ”’AllUsers”’.
Installing Updates
To install new versions of the module, you use the Update-Module
cmdlet:
PS C:> Update-Module -Name AWSPowerShell
Which Should I Choose – MSI or Gallery?
That depends! If you only need the AWS Tools for Windows PowerShell, then you may want to consider uninstalling the version you currently have (which is located in ”C:Program Files (x86)AWS ToolsPowerShellAWSPowerShell”) and moving over to using the PowerShell Gallery instead (or use the -Force
switch with Install-Module
, as noted earlier). Just as we do with the MSI installer, we’ll be keeping the Gallery updated each time we ship a new version so you won’t miss anything whichever approach you use.
If you need the AWS Toolkit for Visual Studio, or want to reference the AWS SDK for .NET assemblies from disk rather than via Nuget, then you may want to consider continuing to use the MSI installer. Note that in the installer, the tools are preselected for installation.
If you are running on an EC2 instance and you want to update the AWSPowerShell module, perhaps to take advantage of new features released between the periodic updating of the Amazon EC2 Windows images, then (provided you have installed the WMF version 5 preview) just run Install-Module
with the -Force
switch as shown earlier.
What Happens If I Use Both?
Install-Module
will report if the requested module is already installed (either from the Gallery or our MSI). In this scenario, you’ll need to use the -Force
switch to cause the Gallery version to be downloaded and installed. When you open shell windows, which version wins depends on your system’s %PSModulePath%
environment variable, but the default values mean that the Gallery versions take precedence, as follows.
The default value of %PSModulePath%
causes PowerShell to first look in your user profile location for modules. So AWSPowerShell installed using Install-Module
with the -Scope CurrentUser
parameter value will be found first. If the module is not located there, PowerShell will then check the system location at ”C:Program FilesWindowsPowerShellModules”. AWSPowerShell installed with the default setting for the -Scope
parameter of Install-Module
will be found. If neither of the locations used by Install-Module
yield the AWSPowerShell module, then any custom paths added to the environment variable will be searched. If you used the MSI installer, your module path will have ”C:Program Files (x86)AWS ToolsPowerShell” after the defaults, and the version installed by our MSI will then be found.
Wrap
We’re very excited to offer access to the AWSPowerShell module from the PowerShell Gallery. Let us know in the comments if there are any other mechanisms you would like us to consider for distributing the tools.