Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 382
Tangiest Avatar asked Dec 01 '09 11:12

Tangiest


Video Answer


2 Answers

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 
like image 197
14 revs, 12 users 69%user156862 Avatar answered Sep 29 '22 19:09

14 revs, 12 users 69%user156862


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.

get-host  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  $PSVersionTable  Name                           Value ----                           ----- CLRVersion                     2.0.50727.4200 BuildVersion                   6.0.6002.18111 PSVersion                      2.0 WSManStackVersion              2.0 PSCompatibleVersions           {1.0, 2.0} SerializationVersion           1.1.0.1 PSRemotingProtocolVersion      2.1 
like image 33
Thomas Bratt Avatar answered Sep 29 '22 21:09

Thomas Bratt