Get the Windows 10 version (e.g. 1909) via CLI (even on a fresh installation)

Updated question

Winver gives you the Windows 10 full version number: Version + Build + "SubBuild", e.g. 1909 (Build 18363.1556) as GUI a window.

I found the ver command which gives the full build number as a CLI output but not the version number or the code name. All other usual CLI suspects like systeminfo etc. don't give you version number either.

Is there a command that will give you the version number (preferably as well as the code name) as a CLI output?

I'm interested in CMD as well as PowerShell. The thing I prefer is a easy to remember command.


Old question (just for reference)

Winver gives you the Windows 10 code name as well as the Windows full version number (Version + Build + "SubBuild") as GUI a window. I found the ver command which gives the full version number as a CLI output but not the code name (code name is called DisplayVersion in the registry since 20H1). All other usual suspects like systeminfo etc. give you a more or less complete version number or the ReleaseId but they don't give you code name either.

Is there a command that give you the code name as a CLI output. I'm interested in CMD as well as PowerShell. The thing I prefer is a easy to remember command.

Note: I checked the answers of the supposed duplicate question, I didn't find any answer which gives you the code name, plz let me know if I overlook it.

Note: The registry holds the code name DisplayVersion-value under the HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion-key. But it gets created only after an update has been made (even if was a minor update did not change the version number).

Note: I just realized, the version number becomes the code name since 20H2.


Solution 1:

This answer was edited after the discussion in the comments. It seems that if you upgrade from a previous install, the following powershell command will work:

(Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('DisplayVersion')

This will query the register key and display its result as text without any object.

In my case, that will display:

20H2

If this doesn't work, then this key is not in your registry, which seems to be the case for a fresh install, but it seems that doing at least one Windows Update run with reboot creates that registry key.

See below what I have in my registry:

enter image description here

Do note, that this is something that changed since version 20H2 and newer. Before that, the codename was equal to the ReleaseId, so if DisplayVersion returns nothing, also check the following command:

(Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseId')