PowerTip: Determine PowerShell Version


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

Comments (7)

  1. V Dalia says:

    Get-Host can also be used.

  2. Chris K says:

    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.

  3. Krunch {The Commenter formerly known as K} says:

    would add, to find more:

    gci variable:

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

  4. Ed Wilson says:

    @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.

  5. ed wilson says:

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

  6. carl says:

    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.

  7. Anonymous says:

    Want to change CRM settings for 3,000 users? Or get CRM organization data without having to call a programmer

Skip to main content