LoginSignup
54
39

More than 1 year has passed since last update.

【PowerShell】アップデート方法(Windows)

Last updated at Posted at 2021-12-02

環境

  • Microsoft Windows 10.0.22000.318(21H2)
  • Windows PowerShell 5.1.22000.613 5.1.19041.1237 → PowerShell 7.2.0
(2022/04/30 追記) 7.2.2 → 7.2.3 アップデート手順


後述のコマンドを実行する方法と全く同じ。今回は各手順のスクリーンショットを並べている。

新バージョンのお知らせ
PowerShell 7.2.2
Copyright (c) Microsoft Corporation.

https://aka.ms/powershell
Type 'help' to get help.

   A new PowerShell stable release is available: v7.2.3
   Upgrade now, or check out the release page at:
     https://aka.ms/PowerShell-Release?tag=v7.2.3

以下を実行する

PowerShell
# Github の PowerShell ページからインストーラをダウンロード
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI"

実行後
セットアップ画面が開く
セットアップ画面
image.png
image.png
image.png
image.png
image.png

以下のコマンドを実行して PowerShell 7.2.3 と表示されることを確認

PowerShell
pwsh -version

アップデート手順

1. 最新版のインストール

の2通りの方法を紹介する。

コマンドを実行する方法

PowerShell を管理者権限で開く -> 以下のコードをコピペして実行

2022/04/30 追記
管理者権限で開かなくても実行できることを確認。(PowerShell 7.2.2 -> 7.2.3)

PowerShell
# Github の PowerShell ページからインストーラをダウンロード
Invoke-Expression "& { $(Invoke-RestMethod https://aka.ms/install-powershell.ps1) } -UseMSI"

セットアップ画面が開く
セットアップ画面

2. セットアップ」に進む

手動でインストールする方法

こちらから最新版(Latest と書かれているもの)で拡張子がmsiのものをダウンロード(2021/12/02現在はPowerShell-7.2.0-win-x64.msi

32bit版 -> x86
64bit版 -> x64
スクリーンショット (14).png
インストーラーを起動

2. セットアップ

「Next」をクリックし続ける。「Optional Actions」については、以下を参考にする。

Optional Actions について

Optional Actions
Add PowerShell to Path Environment Variable:環境変数に PowerShell のパスを追加する
Register Windows Event Logging Manifest:Windows のイベントビューアに PowerShell を登録する(問題があった時にイベントビューアでログを確認できる)
Enable PowerShell remoting:リモート処理を有効化する(sshなどのリモート処理を使う場合は有効化)
Add ‘Open here’ context menus to Explorer:エクスプローラの右クリックメニューに PowerShell を追加する
Add 'Run with PowerShell 7' context menu for PowerShell files:PowerShell ファイルの右クリックメニューに「Run with PowerShell 7(PowerShell 7 で実行)」を追加する

バージョン確認

PowerShell で以下のコマンドを実行してバージョン確認する

PowerShell
$PSVersionTable

以下のように出力される(PSVersion の値を確認)

Name                           Value
----                           -----
PSVersion                      7.2.0
PSEdition                      Core
GitCommitId                    7.2.0
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

バージョン確認は以下のコマンドでも可能

PowerShell
pwsh -version

参考

54
39
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
54
39