How to find powershell version

From Svendsen Tech Powershell Wiki

Jump to: navigation, search

There are several ways to find which version of PowerShell you're running. I demonstrate the ones seemingly most relevant here. If you've looked at the directory structure and found "v1.0" - don't be fooled - it can still be Powershell v2 or later. From what I've read, Microsoft originally had planned to use different directories, but later changed their mind - probably for backwards compatibility reasons if I am to venture a guess.

There's a list of all the different PowerShell executable file system locations here in this article.

Also see this article about a script for finding which version(s) of .NET are installed on remote workstations or servers.

Contents






Displaying PowerShell Version With PowerShell v2 and v3

  • Start PowerShell. If you don't know how, click here.
  • With PowerShell v2 and v3, you can enter $PSVersionTable at the prompt:
PS C:\> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5446
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1


Displaying PowerShell Version With PowerShell v1

With PowerShell version 1, you can inspect the variable $host and the property Version to see which version of PowerShell is running. PowerShell version 1 doesn't have the $PSVersionTable variable mentioned above. The $host variable is in PowerShell v2 as well.

  • Start PowerShell. If you don't know how, click here.

Currently this is the output from PowerShell v2 (I actually don't have any computer still running v1 around):

PS C:\> $host.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

Using Get-Host

You can also use the cmdlet Get-Host:

PS C:\> Get-Host


Name             : ConsoleHost
Version          : 2.0
InstanceId       : a3a9b37c-61a4-478d-bcf6-b3e0f1b93f26
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : nb-NO
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace


Beyond Basics

Yet another way, that returns the same as "$host.Version" in my PowerShell v2, is looking at the default runspace:

PS C:\> [System.Management.Automation.Runspaces.Runspace]::DefaultRunspace.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

Screenshot of PowerShell v3 in Windows 8

Image:Powershell-version-windows8-v3-screenshot.png

Personal tools