PowerTip: Determine PowerShell Version

PowerTip: Determine PowerShell Version

  • Comments 6
  • Likes

Summary: Easily determine the version of Windows PowerShell that is installed.

Hey, Scripting Guy! Question How can I determine what version of Windows PowerShell is installed on my computer?

Hey, Scripting Guy! Answer Use the $psversiontable automatic variable, which is available in Windows PowerShell 2.0 and Windows PowerShell 3.0. 
          (If nothing comes back, you are running Windows PowerShell 1.0.)

PS C:\> $PSVersionTable

 

Name                           Value

----                           -----

PSVersion                      3.0

WSManStackVersion              3.0

SerializationVersion           1.1.0.1

CLRVersion                     4.0.30319.18046

BuildVersion                   6.2.9200.16434

PSCompatibleVersions           {1.0, 2.0, 3.0}

PSRemotingProtocolVersion      2.2

 

To return only the version, access the PSVersion property:

PS C:\> $PSVersionTable.PSVersion

 

Major  Minor  Build  Revision

-----  -----  -----  --------

3      0      -1     -1

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Thanks for that. I've been using $host.version for ages - easier to remember off the top of my head. Pretty sure it works with PowerShell 1.0 too, but it's been a while since I've used a PowerShell 1.0 version.

  • would add, to find more:

    gci variable:\

    add a '$' in front of any of the variables under the name column to use

  • @Chris K. Yes, I like using the automatic $psversionTable variable better than using the $host. To me it is easier. I think it worked back in PowerShell 1 but I do not remember.

    @Krunch you are right it is a great way to see all the variables.

  • Get-Host can also be used.

  • @V Dalia Yes, you are correct. Get-Host does indeed return the PowerShell version information. Thanks for sharing.

  • Actually, the $PSVersionTable command is unreliable compared to get-host. When I use the $PSVersion.psversion command on my Windows 7 PC it returns version 2. When I run it on a Windows 2003 server it returns nothing (the get-host command shows version 1). When I run the $psversion on a Windows 2008 R2 machine -- it also shows nothing (the get-host command shows version 2).

    So using the $PSVersionTable command is unreliable.