2

On the Windows Settings > System > About page, the "Windows specifications" section presents the following information.

Edition Windows 10 Enterprise
Version     20H2
OS build    19042.1288

Using the following reports the Version member as 19042.1288.

(Get-CimInstance -ClassName 'Win32_OperatingSystem').Version

Where can 20H2 be found in a CIM instance? I cannot find it in any of the following CIM instances.

CIM_OperatingSystem
Win32_OperatingSystem
Win32_SystemOperatingSystem
mklement0
  • 382,024
  • 64
  • 607
  • 775
lit
  • 14,456
  • 10
  • 65
  • 119

1 Answers1

1

Indeed, the so-called display version - such as "20H2" - doesn't seem to be a part of the Win32_OperatingSystem (CIM_OperatingSystem appears to be just an alias) and Win32_SystemOperatingSystem CIM (WMI) classes (as of Windows 10 20H2), but you can obtain it from the registry:

Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' DisplayVersion

Similarly, the release ID - such as "2009" - is seemingly also only found in the registry:

Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ReleaseId
mklement0
  • 382,024
  • 64
  • 607
  • 775
  • Does adding a member to report the "so-called display version" to one or more CIM instances seem appropriate? If so, where would be the best place to ask for this? http://github.com/PowerShell/PowerShell? – lit Nov 11 '21 at 15:48
  • @lit, no, I don't think the PowerShell GitHub repo is the best place - PowerShell is just the messenger here. Perhaps you can try via the Feedback Hub app: https://support.microsoft.com/en-us/windows/send-feedback-to-microsoft-with-the-feedback-hub-app-f59187f8-8739-22d6-ba93-f66612949332 – mklement0 Nov 11 '21 at 15:58
  • I have submitted an item on the Feedback Hub. However, I wonder if the request would carry more weight if the PowerShell team told the CIM/WMI team that they have users asking for it. – lit Nov 11 '21 at 16:26
  • Good point, @lit: You could create a PowerShell GitHub issue _too_, explaining the problem and referencing the feedback you've submitted (if there is something to link to) and how you submitted it; perhaps others will follow suit, possibly including PowerShell bigwigs. – mklement0 Nov 11 '21 at 16:33
  • You can easily convert the return value from '(Get-CimInstance -ClassName 'Win32_OperatingSystem').Version' to the display version you are after. Isn't that good enough? – Mogash Nov 11 '21 at 21:02
  • @Mogash, please post an answer with code to "easily convert" from the CIM instance to the display version. I can think f some hard coded ways to do it. But, in general, hard coded is wrong coded. – lit Nov 11 '21 at 21:27
  • @Mogash, the display version being sought here - e.g. `20H2` - isn't part of what `'(Get-CimInstance -ClassName 'Win32_OperatingSystem').Version` returns, e.g. `19042.1288`. – mklement0 Nov 11 '21 at 21:37
  • @mklement0 yes I'm aware of that. I recommend using your approach getting the registry key. But if you for some reason have to use the Get-CimInstance command to get the value you can simply create a function to return the value to the display version. The full table of windows version history is publicly available at: [https://en.wikipedia.org/wiki/Windows_10_version_history](https://en.wikipedia.org/wiki/Windows_10_version_history) – Mogash Nov 11 '21 at 21:46
  • 1
    @Mogash, embedding static information (hard coded) into source code creates a perpetual maintenance cost. and risk. It seems likely that there will be future releases of Windows with new versioning labels. The code could fetch and parse the Wikipedia page but I do not know anyone that would consider that a reasonable or reliable thing to do. – lit Nov 11 '21 at 22:00
  • @Mogash, I agree with lit's assessment, if that's indeed what you're suggesting - honestly, I'm still unclear on what you're actually suggesting. – mklement0 Nov 11 '21 at 22:11
  • @Mogash, please help me understand more clearly what you are suggesting. I am open to any better way to make it work. – lit Nov 12 '21 at 14:28