We can use $PSVersionTable.PSVersion to determine what version of PowerShell is installed on a computer. If the variable does not exist, it is safe to assume that the installed PowerShell version is 1.0.
$PSVersionTable.PSVersion
——— Output ———–
Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
Use the following command to check only Major version of PowerShell.
($PSVersionTable.PSVersion).Major
2
Advertisement