Command to Check PowerShell Version
To check the PowerShell version, open a PowerShell console, type $PSVersionTable
, and Press Enter.
$PSVersionTable
You will see an output like the following:
In the above output, PSVersion is the PowerShell version. In this example, it is PowerShell version 7.
You can get just the value of the PSVersion property by typing the following command:
$PSVersionTable.PSVersion
To get the version number without the header, type the following command:
$PSVersionTable.PSVersion.ToString()
The following three commands will return the Major, Minor, and Patch version, respectively:
$PSVersionTable.PSVersion.Major
$PSVersionTable.PSVersion.Minor
$PSVersionTable.PSVersion.Patch
Note that $PSVersionTable
is not a command. It is a global variable that holds the information about PowerShell—We can check the value of a variable by just typing the name with the dollar sign ($) prefix.
Alternatively, you can also view the value of a variable using the Write-Output
cmdlet:
Write-Output $PSVersionTable
Understanding Different PowerShell Versions
PowerShell 5.1 is the version that comes preinstalled on Windows 10, 11, and Server 2022. PowerShell 7 can run side-by-side with version 5.1.
You can click the link below for instructions on how to install PowerShell 7 on Windows:
How to Install PowerShell 7 on WindowsPowerShell 5.1 uses the powershell.exe
process. PowerShell 7 uses the pwsh.exe
process. That means if you execute a script using the PowerShell
command, it will run on PowerShell 5.1.
To run a script on PowerShell 7, execute the script using the pwsh
command.