Active Directory

Group Policy with WMI Filtering

You can apply policies to clients more flexibly with WMI filters in Group Policy (GPO) by utilizing different rules. When you want to target machines to which a particular group policy should be applied, you can use a set of WMI queries (the WMI Query Language, or WQL) called WMI filters. One way to deploy a policy related to an OU is by utilizing the WMI GPO filter to restrict the policy’s use to computers running Windows 10. This way, the policy won’t apply to computers running older versions of Windows.

What are the WMI GPO filters used for?

When multiple domain objects (users or computers) are located in the flat AD structure rather than the separate OU, or when you need to apply group policies based on the OS version, network settings, installed software, or any other criteria that can be selected using WMI, you can use group policy filtering using WMI (Windows Management Instrumentation). Upon processing a group policy by the client, Windows will verify if it meets with the requested WMI query. If it does, the GPO will be implemented on this particular computer.

Create a New WMI Filter and Link it to a GPO

To create a new WMI filter, open the Group Policy Management console (gpmc.msc and go to Forest -> Domains -> woshub.com -> WMI Filters. This section contains all WMI filters in the AD domain. Create a new WMI filter (New).

WMI-Filter-Win11

WMI Filters

WMI-Filters

Once a WMI filter has been developed, it can be linked to a particular GPO. Locate the desired policy in the GPMC console, then choose your WMI filter from the drop-down list in the WMI Filtering section on the Scope tab. For the purposes of this example, I wish would restrict the policy to Windows 11 computers only.

WMI Filter-Apply-to-policy

Please wait for group policy update, or manually update it using the gpupdate /force command. Use the gpresult /r command to see the policies that have been applied to the client.

The policy will show the status Filtering: Denied (WMI Filter) in the gpresult report if it impacts the client but isn’t applicable because of the WMI filter restrictions.

WMI-Filter-GP-Result

The policy will show the status of WMI filtering policy in the result report, the group policy is being applied to win11 machine.

WMI-Filter-Apllied-to-Win11

GPO WMI Filtering Examples

Let’s explore the several WMI GPO filter examples that are most frequently utilized.

You can select the OS type by using the WMI filter:

  • ProductType=1 – any desktop Windows edition;
  • ProductType=2 – Active Directory domain controller;
  • ProductType=3 – Windows Server.

Windows versions:

  • Windows Server 2016 and Windows 10 — 10.%
  • Windows Server 2012 R2 and Windows 8.1 — 6.3%
  • Windows Server 2012 and Windows 8 — 6.2%
  • Windows Server 2008 R2 and Windows 7 — 6.1%
  • Windows Server 2008 and Windows Vista — 6.0%
  • Windows Server 2003 — 5.2%
  • Windows XP — 5.1%
  • Windows 2000 — 5.0%

WARNING: Please make sure you test these filters fully and confirm they are correct for your use case before applying them to a production environment.


Below is the collection of WMI filters that have collected over the years to assist with narrowing group policy object scopes.

WMI FILTER FOR OPERATING SYSTEM TYPE

WMI FILTER FOR DESKTOP OPERATING SYSTEMS

The below WMI filter is for all windows workstation operating systems.

select * from Win32_OperatingSystem where ProductType="1"

WMI FILTER FOR SERVER OPERATING SYSTEMS (DOMAIN CONTROLLERS ONLY)

The below WMI filter is for all windows server operating systems and are domain controllers.

select * from Win32_OperatingSystem where ProductType="2"

WMI FILTER FOR SERVER OPERATING SYSTEMS (MEMBER SERVERS ONLY)

The below WMI filter is for all windows server operating systems and are not domain controllers.

select * from Win32_OperatingSystem where ProductType="3"

WMI FILTER FOR SERVER OPERATING SYSTEMS (DOMAIN CONTROLLERS AND MEMBER SERVERS)

select * from Win32_OperatingSystem where ProductType="2" or ProductType="3"

WMI FILTER FOR COMPUTER SYSTEM TYPE

WMI FILTER FOR STANDALONE WORKSTATION

select * from Win32_ComputerSystem where DomainRole="0"

WMI FILTER FOR MEMBER WORKSTATION

select * from Win32_ComputerSystem where DomainRole="1"

WMI FILTER FOR STANDALONE SERVER

select * from Win32_ComputerSystem where DomainRole="2"

WMI FILTER FOR MEMBER SERVER

select * from Win32_ComputerSystem where DomainRole="3"

WMI FILTER FOR BACKUP DOMAIN CONTROLLER

select * from Win32_ComputerSystem where DomainRole="4"

WMI FILTER FOR PRIMARY DOMAIN CONTROLLER (PDC)

select * from Win32_ComputerSystem where DomainRole="5"

This is the domain controller that holds the PDC FSMO role


WMI FILTER FOR WINDOWS DESKTOP OPERATING SYSTEMS

WMI FILTER FOR WINDOWS 11 OPERATING SYSTEM VERSION

WMI filter for all Windows 11 Versions

select * from Win32_OperatingSystem where Version like "10.0.2%" and ProductType="1"

WMI filter for Windows 11 (23H2)

select * from Win32_OperatingSystem where Version like "10.0.22631%" and ProductType="1"

WMI filter for Windows 11 (22H2)

select * from Win32_OperatingSystem where Version like "10.0.22621%" and ProductType="1"

WMI filter for Windows 11 (21H2)

select * from Win32_OperatingSystem where Version like "10.0.22000%" and ProductType="1"

WMI FILTER FOR WINDOWS 10 OPERATING SYSTEM VERSION

WMI filter for all Windows 10 Versions

select * from Win32_OperatingSystem where Version like "10.0.1%" and ProductType="1"

WMI filter for Windows 10 (22H2)

select * from Win32_OperatingSystem where Version like "10.0.19045%" and ProductType="1"

WMI filter for Windows 10 (21H2)

select * from Win32_OperatingSystem where Version like "10.0.19044%" and ProductType="1"

WMI filter for Windows 10 (21H1)

select * from Win32_OperatingSystem where Version like "10.0.19043%" and ProductType="1"

WMI filter for Windows 10 (20H2)

select * from Win32_OperatingSystem where Version like "10.0.19042%" and ProductType="1"

WMI filter for Windows 10 (2004)

select * from Win32_OperatingSystem where Version like "10.0.19041%" and ProductType="1"

WMI filter for Windows 10 (1909)

select * from Win32_OperatingSystem where Version like "10.0.18363%" and ProductType="1"

WMI filter for Windows 10 (1903)

select * from Win32_OperatingSystem where Version like "10.0.18362%" and ProductType="1"

WMI filter for Windows 10 (1809)

select * from Win32_OperatingSystem where Version like "10.0.17763%" and ProductType="1"

WMI filter for Windows 10 (1803)

select * from Win32_OperatingSystem where Version like "10.0.17134%" and ProductType="1"

WMI filter for Windows 10 (1709)

select * from Win32_OperatingSystem where Version like "10.0.16299%" and ProductType="1"

WMI filter for Windows 10 (1703)

select * from Win32_OperatingSystem where Version like "10.0.15063%" and ProductType="1"

WMI filter for Windows 10 (1607)

select * from Win32_OperatingSystem where Version like "10.0.14393%" and ProductType="1"

WMI filter for Windows 10 (1511)

select * from Win32_OperatingSystem where Version like "10.0.10586%" and ProductType="1"

WMI filter for Windows 10 (1507)

select * from Win32_OperatingSystem where Version like "10.0.10240%" and ProductType="1"

WMI FILTER FOR WINDOWS 8 AND 8.1 OPERATING SYSTEM VERSIONS

WMI filter for Windows 8 and 8.1

select * from Win32_OperatingSystem where (Version like "6.3%" and ProductType="1") or (Version like "6.2%" and ProductType="1")

WMI FILTER FOR WINDOWS 8.1 OPERATING SYSTEM VERSION

WMI filter for Windows 8.1

select * from Win32_OperatingSystem where Version like "6.3%" and ProductType="1"

WMI FILTER FOR WINDOWS 8 OPERATING SYSTEM VERSION

WMI filter for Windows 8

select * from Win32_OperatingSystem where Version like "6.2%" and ProductType="1"

WMI FILTER FOR WINDOWS 7 OPERATING SYSTEM VERSION

WMI filter for Windows 7

select * from Win32_OperatingSystem where Version like "6.1%" and ProductType="1"

WMI FILTER FOR WINDOWS VISTA OPERATING SYSTEM VERSION

WMI filter for Windows Vista

select * from Win32_OperatingSystem where Version like "6.0%" and ProductType="1"

WMI FILTER FOR WINDOWS XP OPERATING SYSTEM VERSION

WMI filter for Windows XP

select * from Win32_OperatingSystem where (Version like "5.1%" or Version like "5.2%") and ProductType="1"

WMI FILTER FOR WINDOWS 2000 OPERATING SYSTEM VERSION

WMI filter for Windows 2000

select * from Win32_OperatingSystem where Version like "5.0%" and ProductType="1"

WMI FILTER FOR WINDOWS SERVER OPERATING SYSTEMS

STANDARD WINDOWS SERVER RELEASE CHANNEL (LTSC)

WMI filter for Windows Server 2022

select * from Win32_OperatingSystem where Version like "10.0.20348%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2019

select * from Win32_OperatingSystem where Version like "10.0.17763%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2016

select * from Win32_OperatingSystem where Version like "10.0.14393%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2012 R2

select * from Win32_OperatingSystem where Version like "6.3%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2012

select * from Win32_OperatingSystem where Version like "6.2%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2008 R2

select * from Win32_OperatingSystem where Version like "6.1%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2008

select * from Win32_OperatingSystem where Version like "6.0%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2003 and Windows Server 2003 R2

select * from Win32_OperatingSystem where Version like "5.2%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2000

select * from Win32_OperatingSystem where Version like "5.0%" and (ProductType="2" or ProductType="3")

ANNUAL WINDOWS SERVER RELEASE CHANNEL (AC)

WMI filter for Windows Server 23H2

select * from Win32_OperatingSystem where Version like "10.0.25398%" and (ProductType="2" or ProductType="3")

SEMI-ANNUAL WINDOWS SERVER RELEASE CHANNEL (SAC)

WMI filter for Windows Server 20H2

select * from Win32_OperatingSystem where Version like "10.0.19042%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 2004

select * from Win32_OperatingSystem where Version like "10.0.19041%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 1909

select * from Win32_OperatingSystem where Version like "10.0.18363%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 1903

select * from Win32_OperatingSystem where Version like "10.0.18362%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 1809

select * from Win32_OperatingSystem where Version like "10.0.17134%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 1803

select * from Win32_OperatingSystem where Version like "10.0.16299%" and (ProductType="2" or ProductType="3")

WMI filter for Windows Server 1709

select * from Win32_OperatingSystem where Version like "10.0.14393%" and (ProductType="2" or ProductType="3")

WMI FILTER FOR 64-BIT AND 32-BIT OPERATING SYSTEMS

WMI filter for 64-bit operating systems

select * from Win32_Processor where AddressWidth = "64"

WMI filter for 32-bit operating systems

select * from Win32_Processor where AddressWidth = "32"

WMI FILTER FOR HOSTNAME

WMI filter for a device with a spesific hostname.

select * from Win32_ComputerSystem where Name like "computer-name"

WMI filter for devices with the same starting hostname format. (example hostnames: PC01, PC02, PC03, PC04)

select * from Win32_ComputerSystem where Name like "PC%"

WMI FILTER FOR SYSTEM MANUFACTURER

select * from Win32_ComputerSystem where Manufacturer like "%Dell%"

To find the system manufacturer, run: wmic computersystem get manufacturer


WMI FILTER FOR SYSTEM MODEL

select * from Win32_ComputerSystem where Name like "%XPS%"

To find the system model, run: wmic computersystem get model


WMI FILTER FOR DESKTOPS

select * from Win32_ComputerSystem where PCSystemType="1" or PCSystemType="3"

WMI FILTER FOR LAPTOPS

select * from Win32_ComputerSystem where PCSystemType="2"

WMI FILTER FOR DAY OF THE WEEK (MON/TUE/WED/THU/FRI/SAT/SUN)

WMI filter for Monday

select DayOfWeek from Win32_LocalTime where DayOfWeek="1"

WMI filter for Tuesday

select DayOfWeek from Win32_LocalTime where DayOfWeek="2"

WMI filter for Wednesday

select DayOfWeek from Win32_LocalTime where DayOfWeek="3"

WMI filter for Thursday

select DayOfWeek from Win32_LocalTime where DayOfWeek="4"

WMI filter for Friday

select DayOfWeek from Win32_LocalTime where DayOfWeek="5"

WMI filter for Saturday

select DayOfWeek from Win32_LocalTime where DayOfWeek="6"

WMI filter for Sunday

select DayOfWeek from Win32_LocalTime where DayOfWeek="7"

WMI filter for multiple days (Example uses Monday, Tuesday, and Friday)

select DayOfWeek from Win32_LocalTime where DayOfWeek="1" or DayOfWeek="2" or DayOfWeek="5"

WMI FILTER FOR HARD DRIVE TYPE (SSD/HDD)

WMI filter for SSD based systems

select * from MSFT_PhysicalDisk where MediaType="4"

WMI filter for HDD based systems

select * from MSFT_PhysicalDisk where MediaType="3"

So, that’s all in this blog. I will meet you soon with next stuff. Have a nice day!!!

Guys please don’t forget to like and share the post.Also join our WindowsTechno Community and where you can post your queries/doubts and our experts will address them .

You can also share the feedback on below windows techno email id.If you have any questions feel free to contact us on admin@windowstechno.com also follow us on facebook@windowstechno to get updates about new blog posts.

How useful was this post?

Click on a star to rate it!

As you found this post useful...

Follow us on social media!

Was this article helpful?
YesNo

Vipan Kumar

He is an Active Directory Engineer. He has been working in IT industry for more than 10 years. He is dedicated and enthusiastic information technology expert who always ready to resolve any technical problem. If you guys need any further help on subject matters, feel free to contact us on admin@windowstechno.com Please subscribe our Facebook page as well website for latest article. https://www.facebook.com/windowstechno

Leave a Reply

Back to top button