question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get-ComputerInfo command returns wrong data on modern Windows versions

See original GitHub issue

Prerequisites

Steps to reproduce

Invoke the command Get-ComputerInfo on a Windows 11 machine (or up-to-date Windows 10 machine)

Expected behavior

PS> Get-ComputerInfo -Property WindowsProductName, WindowsCurrentVersion

WindowsProductName WindowsCurrentVersion
------------------ ---------------------
Windows 11 Pro     10.0

Actual behavior

PS> Get-ComputerInfo -Property WindowsProductName, WindowsCurrentVersion

WindowsProductName WindowsCurrentVersion
------------------ ---------------------
Windows 10 Pro     6.3

Error details

It seems to me that this error occurs because the Powershell code in this file (https://github.com/PowerShell/PowerShell/blob/8e14d2d7aa1d7bf3c3fbe7b2244c374d4b9f468e/src/Microsoft.PowerShell.Commands.Management/commands/management/GetComputerInfoCommand.cs) gets those values from the `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion` key, which has not been updated in latest Windows versions. Using the Cim to obtain the same information yields the following (correct) result:

~~~
❯  Get-CimInstance Win32_OperatingSystem | Format-Table Caption, Version

Caption                  Version
-------                  -------
Microsoft Windows 11 Pro 10.0.22000
~~~

Environment data

❯  $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.1
PSEdition                      Core
GitCommitId                    7.3.1
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

Issue Analytics

  • State:open
  • Created 8 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
iSazonovcommented, Jan 12, 2023

To summarize the status quo for Windows 10 and above:

Windows 8.1 and above. 😸

1reaction
LorenzoDePasqualecommented, Jan 10, 2023

I’d like to add that the value ReleaseId in the same key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion is out-of-date too, and the same information can be obtained on Windows 10 and 11 with the value DisplayVersion in the same key

Read more comments on GitHub >

github_iconTop Results From Across the Web

get-computerInfo shows totally wrong information
The actual problem is that Get-ComputerInfo pulls its data from the registry (it appears) and since the main registry values haven't been ...
Read more >
Get-ComputerInfo (Microsoft.PowerShell.Management)
The Get-ComputerInfo cmdlet gets a consolidated object of system and operating system ... This command gets all version properties from the computer.
Read more >
Performing networking tasks - PowerShell
To get all IP addresses in use on the local computer, ... This command returns detailed information about DHCP, DNS, routing, ...
Read more >
PowerShell Basics: Are you using Get-ComputerInfo?
With Get-ComputerInfo , an object is returned that contains system and operating system properties. And like all objects in PowerShell, you can ...
Read more >
Programmatically (PowerShell) getting Windows versions.
We have the GUI method to get Windows version and "version", ie Windows 8, 10 or 11 and for Windows 10, we have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found