この記事では、Windows IoT と Nano Server に PowerShell をインストールする方法について説明します。
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 アーキテクチャの場合、IOT_POWERSHELL を含めると Windows PowerShell は追加されません。 そのため、zip ベースのインストールは機能しません。 イメージに追加するには、Import-PSCoreRelease コマンドを使用する必要があります。
Nano Server への展開
以下の手順では、Nano Server が "ヘッドレス" OS であり、あるバージョンの PowerShell が既に実行されていることを前提としています。 詳細については、Nano Server Image Builder のドキュメントをご覧ください。
PowerShell バイナリを展開するには、2 つの方法があります。
- オフライン: Nano Server VHD をマウントし、zip ファイルの中身をマウント イメージ内の選択した場所に展開します。
- オンライン: zip ファイルを PowerShell セッションを介して転送し、選択した場所にそれを展開します。
どちらの場合も、Windows x64 ZIP リリース パッケージが必要です。 PowerShell の "管理者" インスタンス内でコマンドを実行してください。
PowerShell のオフラインでの展開
- お好みの zip ユーティリティを使用して、マウントされた Nano Server イメージ内のディレクトリにパッケージを解凍します。
- イメージをマウント解除し、ブートします。
- 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 サポート ライフサイクル ポリシーによって決まります。 詳細については、以下を参照してください。
winver.exe を実行することで、使用しているバージョンを確認できます。
インストールのサポート
Microsoft は、このドキュメントでインストール方法をサポートしています。 他のソースでは、サードパーティから提供されているインストール方法が利用できる可能性があります。 そのようなツールと方法は機能するかもしれませんが、Microsoft ではそれらの方法をサポートできません。
注
この記事のインストール コマンドは、PowerShell の最新の安定したリリース用です。 別のバージョンの PowerShell をインストールするには、必要なバージョンに合わせてコマンドを調整します。 次のリンクをクリックすると、GitHub の各バージョンの最新リリース ページが表示されます。
- 安定版リリース v7.5。x: https://aka.ms/powershell-release?tag=stable
- LTS リリース v7.4.x: https://aka.ms/powershell-release?tag=lts
- プレビュー リリース v7.6.0-preview:x: https://aka.ms/powershell-release?tag=preview
すべてのパッケージのダウンロード リンクは、リリース ページの [Assets] セクションにあります。 [Assets] セクションは折りたたまれている場合があります。その場合は、クリックして展開する必要があります。
PowerShell