HOW TO: Get PowerShell version info

by Bharat Suneja

While the command ver (short for version) could get you the version info at a DOS/Windows command prompt, and winver does it in the Windows GUI, if you’re stumbling to find the version of Windows PowerShell installed on your computer, the command (cmdlet is the correct and official PowerShell term) you’re looking for is Get-Host.

You can also use the variable $host to get the same information. Note to the Windows PowerShell team – perhaps adding an alias for ver so it works out of the box would’ve been a good idea folks… ! :)

But the PowerShell team did build an easy way to add aliases for cmdlets. To add ver as an alias for the Get-Host cmdlet:

New-Alias ver get-host

The default output from the Get-Host cmdlet includes the Windows PowerShell version and the current locale and language settings.

Name : ConsoleHost
Version : 1.0.0.0
InstanceId : 63970d5c-7cc0-4fb4-9741-aa325b6b2cc3
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy

If you’re on PowerShell 2.0 or later, the output includes PowerShell runspace info:

Name : ConsoleHost
Version : 4.0
InstanceId : 5d3e051e-4e04-4ed7-925f-4f0fb535472d
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Couple of reader comments provide some more functionality. For example, as Aaron commented, to retrieve only the version number without any extra details:

$host.version.tostring()

The $psversiontable environment variable shows version info for additional components:

Name Value
—- —–
PSVersion 4.0
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.34014
BuildVersion 6.3.9600.17090
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion 2.2

For more information, see Get-Host cmdlet reference in Windows PowerShell help.

Also check out Windows PowerShell Version 2 Cmdlets.

{ 8 comments… read them below or add one }

vivek October 4, 2006 at 5:23 pm

or you can type $host. there’s lots of interesting variables, try get-variable and it will show you all.

Reply

Aaron January 8, 2008 at 9:13 am

$env:psver = $host.version.tostring()

Reply

Thomas December 23, 2008 at 3:58 am

One small point I discovered today. This is the version of the HOST, not of PowerShell itself. When run from, say the PowerShell prompt, it is indeed the same version. But if you run this command from the PowerShell Plus prompt, you get a different value (ie the version of the host, or of PowerShell Plus itself).

As we move forward into PowerShell Version 2, this distinction becomes more important.

Reply

liamfinnie February 6, 2009 at 4:10 am

>$PSVersionTable

Name Value
—- —–
CLRVersion 2.0.50727.3082
BuildVersion 6.1.6949.0
PSVersion 2.0
PSCompatibleVersions {1.0, 2.0}

Reply

Anonymous November 3, 2009 at 8:33 am

Thanks, that was very useful information.

Reply

Anonymous January 10, 2010 at 10:24 am

thx

Reply

Anonymous January 28, 2010 at 12:56 pm

Thanks! I was at a loss as to why I did not have PS 2.0 on my WIN7 machine. Of course now that I know how to check the version, I know its 2.0. Life is normal once again.

Reply

Brian Johnson September 18, 2013 at 8:00 am

Thanks.

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: