Introduction
If you are reading this guide because you want to learn how to find the PowerShell version on your computer,you are in the right place!
This guide details 4 ways you can check the version of PowerSell on your computer.
4 Ways to Get the PowerShell Version on your PC
If you want to determine the version of PowerShell on your computer,use one of the methods/commands discussed below:
Method 1: Get PowerShell Version with $PsversionTable Automatic Variable
copy and paste the command below into a PowerShell console and press Enter
$PsversionTable
Here is the result
My current PS version is 5.1.17134.858 but the result contains other information which you may not need.
To display just the version number,use the command below
Here is the result
The last command provides a bit more information. We Now kNow that 5,1,17134,858 represents Major,Minor,Build and Revision numbers.
To display just the Major number,use this command:
$PsversionTable.Psversion.Major
Method 2: Get PS Version with Get-Variable PsversionTable Command
You can also get your PS version using the command below:
powershell -command "(Get-Variable PsversionTable -ValueOnly).Psversion"
The result is the same as the last command
Method 3: Get PowerShell Version with Get-Host Command
Here is another command that will give your PS version
Get-Host
The command returned a result with the full version details
If you want just the version number,you can use any of the 3 commands below:
Get-Host | Select-Object Version
This command will expand the version numbers
Get-Host | Select-Object -ExpandProperty Version
(Get-Host).Version
The last two commands product the same result. Here are the results of the 3 commands
If you want to display just the Major PowerShell version,use this command:
(Get-Host).Version.Major
Method 4: Get Powershell Version with $Host Automatic Variable
To use this method type the following command into a PowerShell prompt. Then press Enter.
$Host
Below is the result of the command in PowerShell
As you can see,the result is the same as using the Get-Host Command
Here is an example:
Conclusion
There are so many reasons you may want to determine the PowerShell version. It may be that you wrote a script that requires a minimum version to run successfully. No matter your reason,I hope it met your need!
If you have any question or want to leave a comment,use the “Leave a Reply” form at the end of this script. Alternatively,you Could share your experience working with PowerShell versions.