Search code examples
windowspowershellcommand-lineversion

How to get the correct Windows version from command line


How to get the correct Windows version from command line, PowerShell included?

As I've tried all solutions/answers from How to find the Windows version from the PowerShell command line, but none is able to give this now:

enter image description here


Solution

  • You can retrieve it from the registry:

    # -> e.g. '22H2'
    Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' DisplayVersion
    

    Note:

    • Apparently only works in version 20H2 and above.

    • Prior to that, winver.exe (whose screenshot is shown in the question), apparently showed the ReleaseId registry value (in lieu of DisplayVersion above).

    • As for terminology: I'm not sure if there's an official name for this information, but, given the name of the registry value, display version sounds reasonable.