Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save roberttoups/8848c8624d6949064e70f51c24e5d7c0 to your computer and use it in GitHub Desktop.
Save roberttoups/8848c8624d6949064e70f51c24e5d7c0 to your computer and use it in GitHub Desktop.
GPO WMI Queries for Windows Operating Systems

GPO WMI Queries for Windows Operating Systems

Product Type

Product Type Operating System
1 Desktop OS
2 Server OS -- Domain Controller
3 Server OS -- Member Server

Workstation OS

General Workstation

# Any Windows Desktop OS -- Method 1
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "1"
# Any Windows Desktop OS -- Method 2
SELECT * FROM Win32_OperatingSystem WHERE (ProductType <> "2") AND (ProductType <> "3")
# Any Windows Desktop OS -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "1" AND NOT OSArchitecture = "64-bit"
# Any Windows Desktop OS -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "1" AND OSArchitecture = "64-bit"

Windows XP (Windows NT)

# Windows XP  -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE (Version LIKE "5.1%" OR Version LIKE "5.2%") AND ProductType="1"
# Windows XP -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE (Version LIKE "5.1%" OR Version LIKE "5.2%") AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows XP -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE (Version LIKE "5.1%" OR Version LIKE "5.2%") AND ProductType="1" AND OSArchitecture = "64-bit"

Windows Vista

# Windows Vista -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="1"
# Windows Vista -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows Vista -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="1" AND OSArchitecture = "64-bit"

Windows 7

# Windows 7 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%" AND ProductType="1"
# Windows 7 -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows 7 -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%" AND ProductType="1" AND OSArchitecture = "64-bit"

Windows 8

# Windows 8 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%" AND ProductType="1"
# Windows 8 -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows 8 -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%" AND ProductType="1" AND OSArchitecture = "64-bit"

Windows 8.1

# Windows 8.1 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%" AND ProductType="1"
# Windows 8.1 -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows 8.1 -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%" AND ProductType="1" AND OSArchitecture = "64-bit"

Windows 10

# Windows 10 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "10%" AND ProductType="1"
# Windows 10 -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "10%" AND ProductType="1" AND NOT OSArchitecture = "64-bit"
# Windows 10 -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "10%" AND ProductType="1" AND OSArchitecture = "64-bit"

Server Operating System

General Server

# Any Windows Server OS
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "2" OR ProductType = "3"
# Any Windows Server OS -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE (ProductType = "2" OR ProductType = "3") AND NOT OSArchitecture = "64-bit"
# Any Windows Server OS -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE (ProductType = "2" OR ProductType = "3") AND OSArchitecture = "64-bit"
# Any Windows Server -- DOMAIN Controller
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "2"
# Any Windows Server -- DOMAIN Controller -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "2" AND NOT OSArchitecture = "64-bit"
# Any Windows Server -- DOMAIN Controller -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "2" AND OSArchitecture = "64-bit"
# Any Windows Server -- Non-DOMAIN Controller
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "3"
# Any Windows Server -- Non-DOMAIN Controller -- 32-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "3" AND NOT OSArchitecture = "64-bit"
# Any Windows Server -- Non-DOMAIN Controller -- 64-bit
SELECT * FROM Win32_OperatingSystem WHERE ProductType = "3" AND OSArchitecture = "64-bit"

Windows Server 2003

# Windows Server 2003 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%"
# Windows Server 2003 -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="2"
# Windows Server 2003 -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="3"
# Windows Server 2003 -- 32-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="2" AND NOT OSArchitecture = "64-bit"
# Windows Server 2003 -- 32-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="3" AND NOT OSArchitecture = "64-bit"
# Windows Server 2003 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="2" AND OSArchitecture = "64-bit"
# Windows Server 2003 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2%" AND ProductType="3" AND OSArchitecture = "64-bit"

Windows Server 2003 R2

# Windows Server 2003 R2 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%"
# Windows Server 2003 R2 -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="2"
# Windows Server 2003 R2 -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="3"
# Windows Server 2003 R2 -- 32-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="2" AND NOT OSArchitecture = "64-bit"
# Windows Server 2003 R2 -- 32-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="3" AND NOT OSArchitecture = "64-bit"
# Windows Server 2003 R2 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="2" AND OSArchitecture = "64-bit"
# Windows Server 2003 R2 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "5.2.3%" AND ProductType="3" AND OSArchitecture = "64-bit"

Windows Server 2008

# Windows Server 2008 -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%"
# Windows Server 2008 -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="2"
# Windows Server 2008 -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="3"
# Windows Server 2008 -- 32-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="2" AND NOT OSArchitecture = "64-bit"
# Windows Server 2008 -- 32-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="3" AND NOT OSArchitecture = "64-bit"
# Windows Server 2008 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="2" AND OSArchitecture = "64-bit"
# Windows Server 2008 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.0%" AND ProductType="3" AND OSArchitecture = "64-bit"

Windows Server 2008 R2

# Windows Server 2008 R2 -- 64-bit -- Any Version
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%"
# Windows Server 2008 R2 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%" AND ProductType="2"
# Windows Server 2008 R2 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.1%" AND ProductType="3"

Windows Server 2012

# Windows Server 2012 -- 64-bit -- Any
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%"
# Windows Server 2012 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%" AND ProductType="2"
# Windows Server 2012 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.2%" AND ProductType="3"

Windows Server 2012 R2

# Windows Server 2012 R2 -- 64-bit -- Any
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%"
# Windows Server 2012 R2 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%" AND ProductType="2"
# Windows Server 2012 R2 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Version LIKE "6.3%" AND ProductType="3"

Windows Server 2016

# Windows Server 2016 -- 64-bit -- Any
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2016%”
# Windows Server 2016 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2016%” AND ProductType="2"
# Windows Server 2016 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2016%” AND ProductType="3"

Windows Server 2019

# Windows Server 2019 -- 64-bit -- Any
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2019%”
# Windows Server 2019 -- 64-bit -- DC
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2019%” AND ProductType="2"
# Windows Server 2019 -- 64-bit -- non-DC
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE “%Windows Server 2019%” AND ProductType="3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment