Get-ComputerInfo command returns wrong data on modern Windows versions
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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:
- Created 8 months ago
- Comments:6 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Windows 8.1 and above. 😸
I’d like to add that the value
ReleaseId
in the same keyHKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion
is out-of-date too, and the same information can be obtained on Windows 10 and 11 with the valueDisplayVersion
in the same key