powershell – Understanding PowerShell’s $PSVersionTable Contents

powershell

If I echo $PSVersionTable in PowerShell, I get what appears to be multiple bits of version information.

The name's of the properties are

  • CLRVersion
  • BuildVersion
  • PSVersion
  • WSManStackVersion
  • PSCompatibleVersions
  • SerializationVersion
  • PSRemotingProtocolVersion

All except 1 are in a normal version notation (#.#.#), and the other 1 of them (PSCompatibleVersions) is a set of version numbers ({1.0, 2.0})

What does each of these represent?


Additionally: This question was created to dig deeper in response to another question I have asked at What Version of Windows Management Framework is Installed?. A comment there, and other comments in a similar question I linked to there, suggest that $PSVersionTable can be used to get the version of WMF. If one of these properties does indeed give the WMF version, and is guaranteed to do so, by all means please answer there too. Also, if you can provide any documentation or evidence of a confirmation, I would give you +2 if I could: my Google queries are not yielding anything satisfactory.

Best Answer

The PowerShell built-in help describes $PSVersionTable:

Get-Help about_Automatic_Variables

You may need to run Update-Help first if you have not run it before.

What's great about Get-Help is you don't have to know exactly what you're looking for. What I typed to find this topic first was actually just help PSVersionTable, and it listed all help topics that contained "PSVersionTable" (there are a few others).

This is the section of about_Automatic_Variables that describes $PSVersionTable, as currently returned by PowerShell for me, but it's the least important part, as the OP noted:

$PsVersionTable Contains a read-only hash table that displays details about the version of Windows PowerShell that is running in the current session. The table includes the following items:

CLRVersion:                The version of the common language runtime (CLR)

BuildVersion:              The build number of the current version

PSVersion:                 The Windows PowerShell version number

WSManStackVersion:         The version number of the WS-Management stack

PSCompatibleVersions:      Versions of Windows PowerShell that are 
                           compatible with the current version

SerializationVersion:      The version of the serialization method

PSRemotingProtocolVersion: The version of the Windows PowerShell remote 
                           management protocol