[gptalk] Re: WMI Filter to exclude Servers

  • From: Thorbjörn Sjövold <thorbjorn.sjovold@xxxxxxxxxxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Wed, 25 Oct 2006 10:07:53 +0200

The way WMI filters works are pretty simple, although troubleshooting them are 
not ;) If the result of the WQL query returns 1 or more objects then this is 
interpreted as true, i.e. the GPO will be applied, if no objects are returned 
it means false and the GPO will not be applied.
If you want to hit everything but Windows 2003 Server (including R2 servers) 
use the following locale independent query:
SELECT * FROM Win32_OperatingSystem WHERE BuildNumber != "3790"
If you still want to use wildcards in your WQL you need to use the LIKE 
operator and the wildcard character %. Since you want the go all the way on 
this bumpy WQL ride and exclude and not include the servers you need to use the 
NOT operator ^, see below for an example. If you want to make it even more 
hardcore you can use OR/AND in the where clause.
The following would hit everything but servers:
SELECT * FROM Win32_OperatingSystem WHERE Caption LIKE "%[^Server]%"
I know that Darren have a tool on gpoguy.com that can you can use to test WQL 
queries, I have not tested myself but my guess since it comes from Darren that 
is works great. Otherwise you are stuck with the built-in WBEMTEST, a tool that 
isn't really a tribute to the MS GUI team :)
Hope it helps.
Thorbjörn Sjövold 
Special Operations Software 
thorbjorn.sjovold a t specopssoft.com 

Download our free tool for remote Gpupdate with graphical reporting, 



From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On 
Behalf Of Omar Droubi
Sent: Wednesday, October 25, 2006 12:49 AM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] WMI Filter to exclude Servers

Hello all,
I have a question:
My current client does not have a great OU structure and we need to implement a 
GPO that updates settings on workstations only.
I haven't used WMI filters too much so I have 2 questions:
1. does the results of the WMI filter exclude those objects or does it include 
the objects?
2. Can someone help me with the syntax? I was starting with something like " 
Select * FROM Win32_OperatingSystem WHERE caption <> "Windows Server 2003"
My issue is how do I write the select statement to include all of my OS names 
and how can I tell it to use a wild card like "Windows Server*"

Other related posts: