次の方法で共有


Windows IoT および Nano Server に PowerShell 7 をインストールする

この記事では、Windows IoT と Nano Server に PowerShell 7 をインストールする方法について説明します。

Windows 11 IoT にデプロイする

Windows 11 IoT Enterprise には、PowerShell 7 のデプロイに使用Windows PowerShell が付属しています。

# Replace the placeholder information for the following variables:
$deviceip = '<device ip address>'
$zipfile = 'PowerShell-7.5.4-win-arm64.zip'
$downloadfolder = 'U:\Users\Administrator\Downloads'
# The download location is local to the device.
# There should be enough space for the zip file and the unzipped contents.

# Create PowerShell session to target device
Set-Item -Path WSMan:\localhost\Client\TrustedHosts $deviceip
$S = New-PSSession -ComputerName $deviceIp -Credential Administrator
# Copy the ZIP package to the device
Copy-Item $zipfile -Destination $downloadfolder -ToSession $S

#Connect to the device and expand the archive
Enter-PSSession $S
Set-Location U:\Users\Administrator\Downloads
Expand-Archive .\PowerShell-7.5.4-win-arm64.zip

# Set up remoting to PowerShell 7
Set-Location .\PowerShell-7.5.4-win-arm64
# Be sure to use the -PowerShellHome parameter otherwise it tries to create a new
# endpoint with Windows PowerShell 5.1
.\Install-PowerShellRemoting.ps1 -PowerShellHome .

PowerShell リモート処理を設定すると、エラー メッセージが表示され、デバイスから切断されます。 PowerShell で WinRM を再起動する必要があります。 これにより、デバイス上の PowerShell 7 エンドポイントに接続できます。


# Be sure to use the -Configuration parameter. If you omit it, you connect to Windows PowerShell 5.1
Enter-PSSession -ComputerName $deviceIp -Credential Administrator -Configuration PowerShell.7.5.4

Windows 11 IoT Coreは、IOT_POWERSHELL 機能を含めることで、Windows PowerShellを追加します。 Windows PowerShell を使用して、Windows 11 IoT Enterprise と同じ手順を使用して PowerShell 7 をデプロイします。

出荷イメージに最新の PowerShell を追加するには、 Import-PSCoreRelease コマンドを使用してパッケージを workarea に含め、 OPENSRC_POWERSHELL 機能をイメージに追加します。

ARM64 アーキテクチャの場合、Windows PowerShell は、IOT_POWERSHELLを含めると追加されません。 そのため、zip ベースのインストールは機能しません。 イメージに追加するには、 コマンドを使用する必要があります。

Nano Server への展開

以下の手順では、Nano Server が "ヘッドレス" OS であり、あるバージョンの PowerShell が既に実行されていることを前提としています。 詳細については、Nano Server Image Builder のドキュメントをご覧ください。

PowerShell バイナリを展開するには、2 つの方法があります。

  1. オフライン: Nano Server VHD をマウントし、zip ファイルの中身をマウント イメージ内の選択した場所に展開します。
  2. オンライン: zip ファイルを PowerShell セッションを介して転送し、選択した場所にそれを展開します。

どちらの場合も、Windows x64 ZIP リリース パッケージが必要です。 PowerShell の "管理者" インスタンス内でコマンドを実行してください。

PowerShell のオフラインでの展開

  1. お好みの zip ユーティリティを使用して、マウントされた Nano Server イメージ内のディレクトリにパッケージを解凍します。
  2. イメージをマウント解除し、ブートします。
  3. Windows PowerShell の組み込みインスタンスに接続します。

PowerShell のオンラインでの展開

次の手順に従って、PowerShell を Nano Server に展開します。

# Replace the placeholder information for the following variables:
$ipaddr = '<Nano Server IP address>'
$credential = Get-Credential # <An Administrator account on the system>
$zipfile = 'PowerShell-7.5.4-win-x64.zip'
# Connect to the built-in instance of Windows PowerShell
$session = New-PSSession -ComputerName $ipaddr -Credential $credential
# Copy the file to the Nano Server instance
Copy-Item $zipfile C:\ -ToSession $session
# Enter the interactive remote session
Enter-PSSession $session
# Extract the ZIP file
Expand-Archive -Path C:\PowerShell-7.5.4-win-x64.zip -DestinationPath 'C:\Program Files\PowerShell 7'

サポートされているバージョンのWindows

Microsoft は、PowerShell がサポート終了または Windows のバージョンがサポート終了になるまで powerShell をサポート

.NET SDK の Docker イメージには、最新バージョンの PowerShell が含まれています。 これらのイメージは、 Microsoft Artifact Registry から入手できます。

これらのイメージには、最新のセキュリティ更新プログラムがない可能性があります。 Microsoft では、最新のセキュリティ更新プログラムが確実に適用されるように、OS パッケージを最新バージョンに更新することを推奨しています。

これらのイメージは、テスト目的で提供されます。 運用ワークロードに Docker イメージが必要な場合は、独自のイメージをビルドして維持する必要があります。

特定のバージョンのWindowsのサポートは、Microsoft サポート ライフサイクル ポリシーによって決まります。 詳細については、以下を参照してください。

を実行することで、使用しているバージョンを確認できます。

サポートされているインストール方法

Microsoft は、このドキュメントでインストール方法をサポートしています。 他のソースでは、サードパーティから提供されているインストール方法が利用できる可能性があります。 そのようなツールと方法は機能するかもしれませんが、Microsoft ではそれらの方法をサポートできません。

この記事のインストール コマンドは、PowerShell の最新の安定したリリース用です。 別のバージョンの PowerShell をインストールするには、必要なバージョンに合わせてコマンドを調整します。 次のリンクをクリックすると、GitHubの各バージョンの最新リリース ページが表示されます。

  • 安定版リリース v7.5。x:
  • LTS リリース v7.4.x:
  • プレビュー リリース v7.6.0-preview:x:

すべてのパッケージのダウンロード リンクは、リリース ページの [Assets] セクションにあります。 [Assets] セクションは折りたたまれている場合があります。その場合は、クリックして展開する必要があります。