Decoding PowerShell build numbers

There are several ways to determine what version of Windows PowerShell you are running on a computer. The most common technique is to use the $PSVersionTable automatic variable:

Decoding PS Build numbers 02

Here, we can see the PowerShell version number in the PSVersion property.

Until PowerShell 5.0 was released as part of Windows Management Framework 5.0, the build number was rounded to .0, such as 1.0, 2.0, 3.0, and 4.0. However, in this new and fast moving pace Microsoft have gotten into, we will see more frequent updates to PowerShell than before. Due to this, the PowerShell version number isn’t simply 5.0 anymore as you might have expected. Now it’s a full build number, such as 5.0.10586.117 for the RTM release of Windows Management Framework 5 for downlevel operating systems.

If you are used to testing preview build of the Windows Management Framework in earlier versions, you might be familiar with the notion of build numbers. However, it’s getting harder to keep track of what build number maps to what version of PowerShell. For example, is 5.0.10586.51 a preview version or an RTM version? Without any form of mapping information, it’s very difficult to know.

Because of this difficulty, I decided to create PowerShell function which can read a mapping table and convert the PSVersion property to a “PSFriendlyVersionName” which makes more sense to a user. Here you can see Get-PSVersion in action:

Decoding PS Build numbers 03

Decoding PS Build numbers 04

Decoding PS Build numbers 05

Decoding PS Build numbers 06

The function is reading a JSON file where the mapping information is defined:

Decoding PS Build numbers 07

Since Microsoft does not provide any PowerShell build number reference, it is up to us – the community – to maintain this mapping information. I have added the RTM build numbers down to version 2 (it does not make sense to add version 1, since PowerShell Remoting which the function leverages was introduced in version 2), but there are a lot of build numbers for preview versions to add.

I have put both the Get-PSVersion function and the JSON file in a PowerShell module, in order to make it easy to download from the PowerShell Gallery. This means you can simply type Install-Module -Name PSVersion  to install it directly from the gallery. Or, you can of course use Save-Module first if you want to inspect the content before installing it. The module is also available on my GitHub account, where you can fork it and send a pull request if you have any contributions to either the Get-PSVersion function or the JSON mapping file. I have also created a TechNet Wiki site called Windows PowerShell build numbers as a reference for those who don`t want to leverage the PSVersion module.

About the author: Jan Egil Ring

Jan Egil works as a Lead Architect at Crayon, Norway. He mainly works with automation, and has a strong passion for PowerShell. He has been working with Microsoft infrastructure products such as Windows Server & System Center since the early 2000s. In the recent years the focus has been more and more related to cloud technologies in Microsoft Azure and hybrid environments. He is a multiple-year recipient of Microsoft Most Valuable Professional Award for his contributions in the Windows PowerShell and Cloud & Datacenter Management technical communities. He speaks regularly at user groups and conferences, such as Nordic Infrastructure Conference (NIC), PowerShell Conference Europe and PowerShell Summit. He is a co-organizer of Azure User Group Norway as well as the MTUG (Microsoft Technology User Group) Script Club which focuses mainly on PowerShell. You can follow him on Twitter @JanEgilRing.

Related Posts