Can someone show me the WMI Filter which will apply for Windows 7 or Windows 10 but not any Server OS?
Can someone show me the WMI Filter which will apply for Windows 7 or Windows 10 but not any Server OS?
use parentheses to group your expression
https://docs.microsoft.com/en-us/windows/win32/wmisdk/where-clause
e.g.
SELECT * FROM Win32_LogicalDisk WHERE (Name = "C:" OR Name = "D:")
AND FreeSpace > 2000000 AND FileSystem = "NTFS"
e.g.
select * from Win32_OperatingSystem WHERE (Version like "10.%" or Version >= "6.1") AND ProductType = "1"
Hello @MISAdmin-6413,
Thank you so much for posting here.
WMI filter for Windows 7:
Select * from Win32_OperatingSystem WHERE Version like "6.1%" and ProductType="1"
WMI filter for Windows 10:
select * from Win32_OperatingSystem where Version like "10.%" and ProductType="1"
For more information, please refer to:
https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-firewall/create-wmi-filters-for-the-gpo#:~:text=To%20create%20a%20WMI%20filter%20that%20queries%20for,filter.%20...%206%20Click%20Add.%20More%20items...%20
For any question, please feel free to contact us.
Best regards,
Hannah Xiong
Thank you. I have seen that article but I am looking for one filter that will check all three conditions... is W7 or W10 but NOT a server OS.
Hello @MISAdmin-6413,
You are welcome. Thank you so much for your kindly reply.
If we need to filter W7 and W10 in one WMI, please try the below WMI filter.
Select * from Win32_OperatingSystem WHERE (Version like "6.1%") or (Version like "10.%") and ProductType="1"
For any question, please feel free to let me know.
Best regards,
Hannah Xiong
Hi. That is similar to the one I was using however, Server 2019 boxes also received the policies (unwanted). Here's what I had...
select * from Win32_OperatingSystem WHERE Version like "10.%" or Version >= "6.1" AND ProductType = "1"
Even though I had ProductType ="1", Server 2019 still received the policies. Will yours prevent the policies from being applied on Server 2019?
Hello @MISAdmin-6413,
Thank you so much for your kindly reply.
Yeah, I did the testing and it will prevent the policy from being applied on Server 2019. Below is the testing:



When checking the gpresult report, we could see the below information:
On W10:
On Server 2019:

On server 2016:

It is suggested that we could run the command gpresult /h C:\report.html on the server 2019 to get the group policy report.
For any question, please feel free to contact us.
Best regards,
Hannah Xiong
Hi. The test that you performed did not include the check for Windows 7... and including that in the same WMI filter is where this becomes tricky.
Hi @MISAdmin-6413,
Thank you so much for your kindly reply.
So sorry that there is no Windows 7 in my lab. So I could not include the check for Windows 7.
As mentioned, Windows 2019 also received the policies. Please kindly run gpresult /h C:\report.html on server 2019 and then check the group policy report. Normally, the GPO should be in the Denied GPOs.
For any question, please feel free to contact us.
Best regards,
Hannah Xiong
Hello @MISAdmin-6413,
Thank you so much for your kindly reply.
I did lots of testing about the WMI filtering. Now I could totally understand that it will become tricky if we add some filters in the same WMI filtering. In my lab, I have Windows server 2019, Windows 10 and Window 8.1.


Then checking the gpresult report, for the Windows server 2019, the GPO is denied due to false WMI filter.

Thanks a lot.
Best regards,
Hannah Xiong
8 people are following this question.