The version field in Windows 10 for versions 2004 or older is in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId registry key, however for versions 20H2 or newer its in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DisplayVersion
I wrote this VBS to output the version for BgInfo for my work https://github.com/tyronewyatt/VisualBasic-Scripts/blob/main/OSVersion2.vbs
I'm no VB expert so please upvote my PowerShell in BgInfo request https://learn.microsoft.com/en-us/answers/questions/487868/bginfo-support-for-powershell-commands-and-scripts.html