powershellwindows-10-desktop

How to get windows version output from Powershell with the same output I get from running winver


enter image description here

I'm looking to have the build version listed out as it is shown there. I've ran every powershell command from the following

How to find the Windows version from the PowerShell command line

The closest to the output is Get-ComputerInfo | select WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

However, it is not giving me the minor version as it is listed with the winver command. winver lists:Build 19045.4170 but that command outputs 10.0.19041.3636

Does anyone know a command which will output the same values as winver?


Solution

  • After way to much digging I found the answer here

    The quick answer is the following copy and pasted into Powershell

    $v = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
    # output like winver does
    'Version {0} (Build {1}.{2})' -f $v.DisplayVersion, $v.CurrentBuildNumber, $v.UBR