Linux または MacOS に AWSPowerShell.NetCore をインストールする - AWS Tools for PowerShell (バージョン 5)

のバージョン 5 (V5) AWS Tools for PowerShell がリリースされました。

変更の中断とアプリケーションの移行については、「移行トピック」を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Linux または MacOS に AWSPowerShell.NetCore をインストールする

前提条件やその他のオプションなど、Linux または macOS AWS Tools for PowerShell への のインストールに関する一般的な情報については、親トピックを参照してください。

にプリインストールされている Tools for PowerShell の詳細については AWS CloudShell、「」を参照してくださいCloudShell にインストール済み

注記

AWSPowerShell.NetCore は、 のインストールに推奨される方法ではありません AWS Tools for PowerShell。推奨される方法については、のインストール AWS.Tools (推奨)代わりに「」を参照してください。

AWSPowerShell.NetCore の新しいリリースにアップグレードするには、Linux または macOS AWS Tools for PowerShell での の更新 の手順に従います。最初に AWSPowerShell.NetCore の以前のバージョンをアンインストールします。

次の 2 つの方法のうちの 1 つで AWSPowerShell.NetCore をインストールできます。

  • AWSPowerShell.NetCore.zip からモジュールをダウンロードし、モジュールディレクトリの 1 つにそのモジュールを展開します。$Env:PSModulePath 変数の値を出力することで、モジュールディレクトリを検出できます。

  • 次の手順で説明するように、Install-Module コマンドレットを使用して PowerShell ギャラリーからインストールする。

Install-Module コマンドレットを使用して Linux または macOS に AWSPowerShell.NetCore をインストールするには

次のコマンドを実行して、PowerShell コアセッションを開始します。

$ pwsh
注記

sudo pwsh を実行して、昇格された、管理者権限で PowerShellを実行することで PowerShell を起動しないことをお勧めします。これは、潜在的なセキュリティリスクを避けるためであり、最小限の特権の原則にも反します。

PowerShell ギャラリーから AWSPowerShell.NetCore 単一モジュールパッケージをインストールするには、次のコマンドを実行します。

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

リポジトリが「信頼されていない」と通知された場合は、インストールするかどうかを尋ねられます。PowerShell がモジュールをインストールできるようにするには、y を入力します。リポジトリを信頼せずにプロンプトを回避するには、次のコマンドを実行します。

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

コンピュータ AWS Tools for PowerShell のすべてのユーザーに をインストールしない限り、このコマンドを root として実行する必要はありません。これを行うには、sudo pwsh を使用して開始した PowerShell セッションで、次のコマンドを実行します。

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

スクリプトの実行

Set-ExecutionPolicy コマンドは、Windows 以外のシステムでは使用できません。Get-ExecutionPolicy は実行できます。これは、Windows 以外のシステムで実行されている PowerShell Core のデフォルトの実行ポリシー設定が Unrestricted であることを示します。詳細については、Microsoft Technet ウェブサイトの「About Execution Policies」を参照してください。

には AWS モジュールのディレクトリの場所PSModulePathが含まれているため、 Get-Module -ListAvailable コマンドレットにはインストールしたモジュールが表示されます。

AWSPowerShell.NetCore

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

AWS Tools for PowerShell Core を使用するための PowerShell コンソールの設定 (AWSPowerShell.NetCore のみ)

PowerShell Core は、通常、モジュールでコマンドレットを実行するたびにモジュールを自動的にロードします。しかし、これはサイズが大きいため AWSPowerShell.NetCore には機能しません。AWSPowerShell.NetCore コマンドレットの実行を開始するには、まず Import-Module AWSPowerShell.NetCore コマンドを実行する必要があります。これは、AWS.Tools モジュール内のコマンドレットには必要ありません。

PowerShell セッションの初期化

のインストール後に Linux ベースまたは macOS ベースのシステムで PowerShell を起動する場合は AWS Tools for PowerShell、Initialize-AWSDefaultConfiguration を実行して、使用する AWS アクセスキーを指定する必要があります。Initialize-AWSDefaultConfiguration の詳細については、「AWS 認証情報の使用」を参照してください。

注記

の以前の (3.3.96.0 より前の) リリースでは AWS Tools for PowerShell、このコマンドレットの名前は でしたInitialize-AWSDefaults

バージョニング

AWS は、新しい AWS サービスや機能をサポートするために、 の新しいバージョン AWS Tools for PowerShell を定期的にリリースします。インストール AWS Tools for PowerShell した のバージョンを確認するには、Get-AWSPowerShellVersion コマンドレットを実行します。

例:

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]

現在のバージョンのツールでサポートされている AWS サービスのリストを表示するには、Get-AWSPowerShellVersion コマンドレットに -ListServiceVersionInfoパラメータを追加します。

実行中の PowerShell のバージョンを確認するには、「$PSVersionTable」と入力して、$PSVersionTable 自動変数の内容を表示します。

例:

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

Linux または macOS AWS Tools for PowerShell での の更新

の更新バージョン AWS Tools for PowerShell がリリースされたら、定期的にローカルで実行しているバージョンを更新する必要があります。

Tools for PowerShell Core の更新

Get-AWSPowerShellVersion コマンドレットを実行して実行中のバージョンを確認し、PowerShell Gallery ウェブサイトにある Tools for Windows PowerShell のバージョンと比較します。2~3 週間ごとにチェックすることをお勧めします。新しいコマンドと AWS サービスのサポートは、そのサポートでバージョンに更新した後にのみ利用できます。

AWSPowerShell.NetCore の新しいリリースをインストールする前に、既存のモジュールをアンインストールします。既存のパッケージをアンインストールする前に、開いているすべての PowerShell セッションを閉じます。次のコマンドを実行して、パッケージをアンインストールします。

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

パッケージがアンインストールされたら、次のコマンドを実行して、更新されたモジュールをインストールします。

PS > Install-Module -Name AWSPowerShell.NetCore

インストール後、コマンド Import-Module AWSPowerShell.NetCore を実行して、更新されたコマンドレットを PowerShell セッションにロードします。

関連情報