Using PowerShell to determine the installed version of Windows

You can determine the version of Microsoft Windows installed on a system from a PowerShell prompt using [System.Environment]::OSVersion.Version or (Get-WmiObject -class Win32_OperatingSystem).Caption.

Learning Windows PowerShell
Learning Windows PowerShell
1x1 px

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

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      15063  0


PS C:\Users\Public> (Get-WmiObject -class Win32_OperatingSystem).Caption
Microsoft Windows 10 Pro
PS C:\Users\Public> (Get-WmiObject -class Win32_OperatingSystem)


SystemDirectory : C:\WINDOWS\system32
Organization    : Microsoft
BuildNumber     : 15063
RegisteredUser  : Jeanne
SerialNumber    : 00330-80000-00000-AA775
Version         : 10.0.15063



PS C:\Users\Public>

You can also use Get-CimInstance.

PS C:\Users\Public> Get-CimInstance win32_operatingsystem

SystemDirectory     Organization BuildNumber RegisteredUser SerialNumber            Version
---------------     ------------ ----------- -------------- ------------            -------
C:\WINDOWS\system32 Microsoft    15063       Jeanne         00330-80000-00000-AA765 10.0.15063


PS C:\Users\Public> Get-CimInstance win32_operatingsystem | select Version

Version
-------
10.0.15063


PS C:\Users\Public>

Get-WmiObject can be abbreviated to gwmi and Get-CimInstance can be abbreviated to gcim.

PS C:\Users\Public> gwmi win32_operatingsystem | % caption
Microsoft Windows 10 Pro
PS C:\Users\Public gcim win32_operatingsystem | % caption
Microsoft Windows 10 Pro
PS C:\Users\Public>

If you want to know when the current operating system was installed and whether it is a 32-bit or 64-bit version of Windows, you can use the command below.

PS C:\Users\Public> gcim Win32_OperatingSystem | select Caption, Version, InstallDate, OSArchitecture

Caption                  Version    InstallDate          OSArchitecture
-------                  -------    -----------          --------------
Microsoft Windows 10 Pro 10.0.15063 7/17/2017 9:09:48 AM 64-bit


PS C:\Users\Public>

You can determine the installation history of security patches to the operating system with Get-CimInstance -Class win32_quickfixengineering .

PS C:\Users\Public> Get-CimInstance -Class win32_quickfixengineering

Source        Description      HotFixID      InstalledBy          InstalledOn
------        -----------      --------      -----------          -----------
              Update           KB4022405     NT AUTHORITY\SYSTEM  7/18/2017 12:00:00 AM
              Security Update  KB4038806     NT AUTHORITY\SYSTEM  9/12/2017 12:00:00 AM
              Security Update  KB4049179     NT AUTHORITY\SYSTEM  10/17/2017 12:00:00 AM
              Security Update  KB4041676     NT AUTHORITY\SYSTEM  10/11/2017 12:00:00 AM


PS C:\Users\Public>

Note: commands tested on Windows 10 Professional system running PowerShell 5.1.

Related articles:

  1. Determining the version of Microsoft Windows from the command line
  2. Determining which version of Windows 10 is installed
  3. Determining whether the Windows 10 Anniversary Update is installed
  4. List Installed Security Patches with PowerShell