PowerShell 5.1からPowerShell 7へアップデートしてみた【Windows 11】

環境構築

はじめに

Windowsには最初からPowerShellが入っていますが、長らく使っていると PowerShell 5.1 のままという人も少なくありません。

私の環境もPowerShell 5.1だったため、最新版のPowerShellへアップデートしてみました。

この記事では、PowerShellのバージョン確認からインストール、動作確認までを紹介します。


PowerShell 5.1とは?

PowerShell 5.1はWindowsに標準搭載されているPowerShellです。

しかし現在は、Microsoftが開発を続けているPowerShell 7の利用が推奨されます。

Microsoftによると、PowerShell 7は高速で安全性が向上しており、現在も積極的に開発・サポートされているようです。
一方、Windows PowerShell 5.1は新機能の開発が終了しており、セキュリティ更新のみが提供されているようです。

PowerShell 7 is faster, more secure, and is available for Windows, Linux and macOS. PowerShell 7 is actively developed and supported. Windows PowerShell 5.1 is no longer being developed. For more information, see the Differences between Windows PowerShell 5.1 and PowerShell 7 article.

引用:Windows PowerShell update message FAQ

普段からPowerShellを使うなら、7へ移行しておくメリットは大きいでしょう。

PowerShell 7にアップデート後、PowerShell 5.1は消える?

Windows PowerShell 5.1がPowerShell 7へ置き換わるわけではなく、PowerShell 7は別環境としてインストールされ、Windows PowerShell 5.1と並行して利用できるようです。
厳密にはアップデートではないみたいですね。

PowerShell 7 doesn’t replace Windows PowerShell 5.1. It installs to a new directory and runs side-by-side with Windows PowerShell 5.1. There are some Windows PowerShell modules that can be run using the PowerShell 7 Windows Compatibility feature. Other modules require that you run them in Windows PowerShell 5.1. For more information, see PowerShell 7 module compatibility.

引用:Install PowerShell 7 on Windows

現在のバージョンを確認する

PowerShellを開き、次のコマンドを実行します。

$PSVersionTable.PSVersion

私の環境では次のように表示されました。

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      26100  8972

5.1であれば、Windows標準のPowerShellです。


PowerShell 7をインストールする

最も簡単なのは winget を利用する方法です。

winget install Microsoft.PowerShell

次のように表示されれば成功です。

見つかりました PowerShell [Microsoft.PowerShell] バージョン 7.6.4.0
このアプリケーションは所有者からライセンス供与されます。
Microsoft はサードパーティのパッケージに対して責任を負わず、ライセンスも付与しません。
インストーラーハッシュが正常に検証されました
パッケージのインストールを開始しています...
  ██████████████████████████████  100%
インストールが完了しました

インストール後、”Windows PowerShell”ではなく、”PowerShell”を起動することでPowerShell 7が利用できます。

ゆるユーリ
ゆるユーリ

”Windows PowerShell”を選択すると、従来のPowerShell 5.1が起動するみたいだね。


バージョンを確認する

PowerShell 7を起動して、もう一度確認します。

$PSVersionTable.PSVersion

例えば次のように表示されれば成功です。

Major  Minor  Patch  PreReleaseLabel BuildLabel
-----  -----  -----  --------------- ----------
7      6      4

※バージョン番号は2026/8/2時点のものです。今後更新される場合があります。


ターミナルのデフォルトをPowerShell 7に更新する

PowerShell 7をインストールしても、ターミナル起動時はPowerShell 5.1が起動してしまいます。
既定のプロファイルを変更しましょう。

1. ターミナルの設定を開く

上部の矢印からメニューを開く。
設定を選択

2.スタートアップ > 既定のプロファイルを”Windows PowerShell”→”PowerShell”に変更

PowerShell を選択する
保存する

以上で、ターミナル起動時にPowerShell 7が起動するようになります。


どちらを使えばいい?

基本的には PowerShell 7 を使うことをおすすめします。

ただし、古いWindows専用モジュールの中にはPowerShell 5.1でしか動作しないものもあります。

普段の開発や自動化にはPowerShell 7、古い管理ツールが必要な場合だけPowerShell 5.1を利用するという使い分けがよさそうです。


おわりに

PowerShell 7へのアップデートは数分で完了し、PowerShell 5.1と共存できるため安心して導入できます。

これからPowerShellを使い始める方や、開発環境を整えたい方は、一度アップデートしてみてはいかがでしょうか。

タイトルとURLをコピーしました