8

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.

9

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
  • +1 for obvious simplicity. I was working on a long-winded reply and when I saw this, I deleted the whole thing because this says in fewer, simpler words all that really needs to be said. – Ryan Ries Sep 10 '14 at 20:28
  • Thank you! I was actually hoping that there might be some way of collecting meta-information from right within PowerShell. This provided an answer and will probably help even beyond the scope of the question. Not that last additional bit, but this gets me 1 step closer to that too. Thanks again. – Loduwijk Sep 10 '14 at 20:41
  • PowerShell's built in help is one of my favorite features, and learning how to leverage it to guess and find things really helps speed up getting to know PowerShell. I should also note that I had no idea the documentation for this variable was in About_Automatic_Variables... what I actually typed was help PSVersionTable, and it listed help topics that mention PSVersionTable since there was not an exact match. – Joshua McKinnon Sep 10 '14 at 21:24
1

From my experience, the PSVersion, which is the PowerShell version matches the WMF version, at least as far as the major version numbers go. I haven't tracked all of the preview releases to see how those match up, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.