Determine installed PowerShell version

Determine installed PowerShell version

How can I determine what version of PowerShell is installed on a computer, and indeed if it is installed at all?


Solution 1:

Use $PSVersionTable.PSVersion to determine the engine version. If the variable does not exist, it is safe to assume the engine is version 1.0.

Note that $Host.Version and (Get-Host).Version are not reliable – they reflect
the version of the host only, not the engine. PowerGUI,
PowerShellPLUS, etc. are all hosting applications, and
they will set the host’s version to reflect their product
version — which is entirely correct, but not what you’re looking for.

PS C:\> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1

Solution 2:

I would use either Get-Host or $PSVersionTable. As Andy Schneider points out, $PSVersionTable doesn’t work in version 1; it was introduced in version 2.


Name             : ConsoleHost
Version          : 2.0
InstanceId       : d730016e-2875-4b57-9cd6-d32c8b71e18a
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-GB
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace


Name                           Value
----                           -----
CLRVersion                     2.0.50727.4200
BuildVersion                   6.0.6002.18111
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
PSRemotingProtocolVersion      2.1

Solution 3:

You can look at the built in variable, $psversiontable. If it doesn’t exist, you have V1. If it does exist, it will give you all the info you need.

1 >  $psversiontable

Name                           Value                                           
----                           -----                                           
CLRVersion                     2.0.50727.4927                                  
BuildVersion                   6.1.7600.16385                                  
PSVersion                      2.0                                             
WSManStackVersion              2.0                                             
PSCompatibleVersions           {1.0, 2.0}                                      
PSRemotingProtocolVersion      2.1    

Solution 4:

To determine if PowerShell is installed, you can check the registry for the existence of




and, if it exists, whether the value is 1 (for installed), as detailed in the blog post Check if PowerShell installed and version.

To determine the version of PowerShell that is installed, you can check the registry keys




To determine the version of PowerShell that is installed from a .ps1 script, you can use the following one-liner, as detailed on in Which PowerShell Version Am I Running.

$isV2 = test-path variable:\psversiontable

The same site also gives a function to return the version:

function Get-PSVersion {
    if (test-path variable:psversiontable) {$psversiontable.psversion} else {[version]""}

Solution 5:

You can directly check the version with one line only by invoking PowerShell externally, such as from Command Prompt

powershell -Command "$PSVersionTable.PSVersion"

According to @psaul you can actually have one command that is agnostic from where it came (CMD, PowerShell or Pwsh). Thank you for that.

powershell -command "(Get-Variable PSVersionTable -ValueOnly).PSVersion"

I’ve tested and it worked flawlessly on both CMD and PowerShell.


Solution 6:

You can verify that Windows PowerShell version installed by completing the following check:

  1. Click Start, click All Programs, click Accessories, click Windows PowerShell, and then click Windows PowerShell.
  2. In the Windows PowerShell console, type the following command at the command prompt and then press ENTER:

    Get-Host | Select-Object Version

You will see output that looks like this: