Does anybody know how to get the OS Version like this:

OS Version: 1607

With using Get-WmiObject? Couldn't find this Informatin at all..

  • What is the reason you are using Powershell? – marijnr Jun 11 '18 at 7:32
  • I have to implement this information in a desktop information software and the only way I can do this is with an .ini file and a WMI query – j.walt Jun 11 '18 at 7:34
  • 1
    The powershell tag is still unclear, nevertheless: (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseID') – LotPings Jun 11 '18 at 8:09
  • Have you tried (Get-WmiObject Win32_OperatingSystem).Version? – Sandeep Jun 11 '18 at 9:07
  • @Sandeep Version will get you the ID Microsoft uses to identify their Windows version (version 6.1 is used for Windows 7, version 6.2 is used for Windows 10, ...) – marijnr Jun 11 '18 at 9:23

The OS version is stored in a Registry Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId. Normally you can read those keys using WMI.

LotPings has provided the correct query in the comments: (Get-Item "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion").GetValue('ReleaseID')


It's not through the WMI, but Jeff Mercado answer might be to any help anyhow;

Since you have access to the .NET library, you could access the OSVersion property of the System.Environment class to get this information. For the version number, there is the Version property.

For example,

PS C:\> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
6      1      7601   65536

Details of Windows versions can be found here.


Here is a little script I wrote to find computer information:

Powershell: Get Computer Info

$Computer = "localhost"
$Manufacturer = Get-WmiObject -ComputerName $Computer -class win32_computersystem | select -ExpandProperty Manufacturer
$Model = Get-WmiObject -class win32_computersystem -ComputerName $Computer | select -ExpandProperty model
$Serial = Get-WmiObject -class win32_bios -ComputerName $Computer | select -ExpandProperty SerialNumber
$wmi_os = Get-WmiObject -class Win32_OperatingSystem -ComputerName $Computer | select CSName,Caption,Version,OSArchitecture,LastBootUptime
$wmi_cpu = Get-WmiObject -class Win32_Processor -ComputerName $Computer | select -ExpandProperty DataWidth
$wmi_memory = Get-WmiObject -class cim_physicalmemory -ComputerName $Computer | select Capacity | %{($_.Capacity / 1024kb)}
$DNName = Get-ADComputer -Filter "Name -like '$Computer'" | select -ExpandProperty DistinguishedName
[TimeSpan]$uptime = New-TimeSpan $Boot $(get-date)
Write-Host "------Computer Info for $Computer------------------`r"
Write-Host "Hostname from WMI`: $($wmi_os.CSName)"
Write-Host "$DNName"
Write-Host "$Manufacturer $Model SN`:$Serial"
Write-Host "$($wmi_os.Caption) $wmi_build $($wmi_os.OSArchitecture) $($wmi_os.Version)"
Write-Host "CPU Architecture: $wmi_cpu"
Write-Host "Memory: $wmi_memory"
Write-Host "Uptime`: $($uptime.days) Days $($uptime.hours) Hours $($uptime.minutes) Minutes $($uptime.seconds) Seconds"
Write-Host "--------------------------------------------------------"

Found this cool script at TechNet Gallary: Get-WindowsVersion

Here is how it looks:

[19JUN] :>Get-WindowsVersion -ComputerName ktpc

ComputerName Productname           WindowsVersion WindowsBuild   ProductID               InstallTime
------------ -----------           -------------- ------------   ---------               -----------
KTPC         Windows 10 Enterprise 1803           10.0.17134.112 00329-10280-00000-AA451 5/22/2018 8:10:15 AM

It utilizes the same "RealseID" as others suggested to get this value. However, it is nice effort and ready to use.


It's not using Get-WmiObject, but check this out:

Get-ComputerInfo | Select-Object @{Name='Operating System';Expression={$.OsName}}, @{Name='Version';Expression={$.WindowsVersion}}, @{Name='Build';Expression={$.OsBuildNumber}}, @{Name='Architecture';Expression={$.OsArchitecture}}, @{Name='System Root';Expression={$.WindowsSystemRoot}}, @{Name='Language';Expression={$.OsLanguage}}, @{Name='Boot State';Expression={$_.CsBootupState}} | Format-Table


Get-ItemProperty 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion' | Select-Object ProductName, ReleaseID, CurrentBuild, SystemRoot


Simply take my program and run with it. I'm working on a new version already and hope to have it released soon, as the new version uses a lot more PowerShell and a lot less WMIC commands.



Isn't a simple answer to the original question as follows:

Get-ComputerInfo | select windowsversion

WindowsVersion -------------- 1903

New contributor
Soroosh is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • And to do it against other PCs in the same domain when you have Admin rights, use "Invoke-Command -ComputerName PCNAME {Get-ComputerInfo | select windowsversion}" – Christopher Hostage Oct 9 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.