PowerShellのバージョンを確認する方法

toc目次

はじめに

よく忘れるので、個人的なメモです。

PowerShellのバージョンを確認する

PowerShell(powershell.exe)で、$PSVersionTableと入力し実行すると確認できます。

PS > $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.3930
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3930
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

出力結果のPSVersionの値がPowerShellのバージョンです。

PowerShell 7(pwsh.exe)での実行結果は以下の通りです。

PS > $PSVersionTable

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