Get the OS Version from the Command Line

by Jul 22, 2025IT Tips0 comments

Correct

Get-ComputerInfo outputs the correct OSName

 Get-ComputerInfo | Select-Object OSName,OSDisplayVersion

OsName                          OSDisplayVersion
------                          ----------------
Microsoft Windows 11 Enterprise 24H2

Using Format-List

 Get-ComputerInfo | fl OSName,OSDisplayVersion


OsName           : Microsoft Windows 11 Enterprise
OSDisplayVersion : 24H2

Incorrect

(Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion") | Select-Object -Property ProductName,DisplayVersion                                                                                                                                                
                  

This looks like a solution but the output is incorrect the ProductName says "Windows 10 Enterprise" and should be Windows 11 Enterprise

ProductName           DisplayVersion
-----------           --------------
Windows 10 Enterprise 24H2

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.