Install AWSPowerShell.NetCore on Linux or macOS - Amazon Tools for PowerShell (version 5)
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Version 5 (V5) of the Amazon Tools for PowerShell has been released!

For information about breaking changes and migrating your applications, see the migration topic.

Install AWSPowerShell.NetCore on Linux or macOS

For general information about installing the Amazon Tools for PowerShell on Linux or macOS, including prerequisites and other options, see the parent topic.

For information about the Tools for PowerShell that are pre-installed on Amazon CloudShell, see Installed on CloudShell.

Note

AWSPowerShell.NetCore is not the recommended method for installing the Amazon Tools for PowerShell. For the recommended method, see Install AWS.Tools (recommended) instead.

To upgrade to a newer release of AWSPowerShell.NetCore, follow the instructions in Updating the Amazon Tools for PowerShell on Linux or macOS. Uninstall earlier versions of AWSPowerShell.NetCore first.

You can install AWSPowerShell.NetCore in one of two ways:

  • Downloading the module from AWSPowerShell.NetCore.zip and extracting it in one of the module directories. You can discover your module directories by printing the value of the $Env:PSModulePath variable.

  • Installing from the PowerShell Gallery using the Install-Module cmdlet as described in the following procedure.

To install AWSPowerShell.NetCore on Linux or macOS using the Install-Module cmdlet

Start a PowerShell Core session by running the following command.

$ pwsh
Note

We recommend that you don't start PowerShell by running sudo pwsh to run PowerShell with elevated, administrator rights. This is because of the potential security risk and is inconsistent with the principle of least privilege.

To install the AWSPowerShell.NetCore single-module package from the PowerShell Gallery, run the following command.

PS > Install-Module -Name AWSPowerShell.NetCore Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y

If you are notified that the repository is "untrusted", you are asked if you want to install anyway. Enter y to allow PowerShell to install the module. To avoid the prompt without trusting the repository, you can run the following command.

PS > Install-Module -Name AWSPowerShell.NetCore -Force

You don't have to run this command as root, unless you want to install the Amazon Tools for PowerShell for all users of a computer. To do this, run the following command in a PowerShell session that you have started with sudo pwsh.

PS > Install-Module -Scope AllUsers -Name AWSPowerShell.NetCore -Force

Script Execution

The Set-ExecutionPolicy command isn't available on non-Windows systems. You can run Get-ExecutionPolicy, which shows that the default execution policy setting in PowerShell Core running on non-Windows systems is Unrestricted. For more information, see About Execution Policies on the Microsoft Technet website.

Because the PSModulePath includes the location of the Amazon module's directory, the Get-Module -ListAvailable cmdlet shows the module that you installed.

AWSPowerShell.NetCore

PS > Get-Module -ListAvailable Directory: /Users/username/.local/share/powershell/Modules ModuleType Version Name ExportedCommands ---------- ------- ---- ---------------- Binary 3.3.563.1 AWSPowerShell.NetCore

Configure a PowerShell Console to Use the Amazon Tools for PowerShell Core (AWSPowerShell.NetCore Only)

PowerShell Core typically loads modules automatically whenever you run a cmdlet in the module. But this doesn't work for AWSPowerShell.NetCore because of its large size. To start running AWSPowerShell.NetCore cmdlets, you must first run the Import-Module AWSPowerShell.NetCore command. This isn't required for cmdlets in AWS.Tools modules.

Initialize Your PowerShell Session

When you start PowerShell on a Linux-based or macOS-based system after you have installed the Amazon Tools for PowerShell, you must run Initialize-AWSDefaultConfiguration to specify which Amazon access key to use. For more information about Initialize-AWSDefaultConfiguration, see Using Amazon Credentials.

Note

In earlier (before 3.3.96.0) releases of the Amazon Tools for PowerShell, this cmdlet was named Initialize-AWSDefaults.

Versioning

Amazon releases new versions of the Amazon Tools for PowerShell periodically to support new Amazon services and features. To determine the version of the Amazon Tools for PowerShell that you have installed, run the Get-AWSPowerShellVersion cmdlet.

For example:

PS > Get-AWSPowerShellVersion AWS Tools for PowerShell Version 5.0.3 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Amazon Web Services SDK for .NET Core Runtime Version 4.0.0.13 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. Release notes: https://github.com/aws/aws-tools-for-powershell/blob/main/changelogs/CHANGELOG.ALL.md This software includes third party software subject to the following copyrights: - Logging from log4net, Apache License [http://logging.apache.org/log4net/license.html]

To see a list of the supported Amazon services in the current version of the tools, add the -ListServiceVersionInfo parameter to a Get-AWSPowerShellVersion cmdlet.

To determine the version of PowerShell that you are running, enter $PSVersionTable to view the contents of the $PSVersionTable automatic variable.

For example:

PS > $PSVersionTable Name Value ---- ----- PSVersion 6.2.2 PSEdition Core GitCommitId 6.2.2 OS Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

Updating the Amazon Tools for PowerShell on Linux or macOS

Periodically, as updated versions of the Amazon Tools for PowerShell are released, you should update the version that you are running locally.

Update the Tools for PowerShell Core

Run the Get-AWSPowerShellVersion cmdlet to determine the version that you are running, and compare that with the version of Tools for Windows PowerShell that is available on the PowerShell Gallery website. We suggest you check every two to three weeks. Support for new commands and Amazon services is available only after you update to a version with that support.

Before you install a newer release of AWSPowerShell.NetCore, uninstall the existing module. Close any open PowerShell sessions before you uninstall the existing package. Run the following command to uninstall the package.

PS > Uninstall-Module -Name AWSPowerShell.NetCore -AllVersions

After the package is uninstalled, install the updated module by running the following command.

PS > Install-Module -Name AWSPowerShell.NetCore

After installation, run the command Import-Module AWSPowerShell.NetCore to load the updated cmdlets into your PowerShell session.

Related Information