The current Windows version can be read easily from the Windows Registry:
PS> Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object -Property ReleaseId, DisplayVersion ReleaseId DisplayVersion --------- -------------- 2009 20H2
Be aware though that the information shown in ReleaseId is deprecated. New Windows 10 builds use the DisplayVersion property instead. To correctly identify Windows 10 versions, make sure to use DisplayVersion and not ReleaseId.
In the example above you can see that Windows 10 reports the same ReleaseId (2009) for a number of different builds. DisplayVersion 20H1, for example, also uses the ReleaseId 2009.
Microsoft announced that ReleaseId was deprecated and can no longer be used to correctly identify Windows 10 builds. This may be important for scripts and also tools like WSUS, WAC and others. Cmdlets like Get-WindowsImage, for example, now have difficulties to identify the correct Windows 10 version.