[gptalk] Re: GPO WMI/WQL Filter

  • From: "Nelson, Jamie" <Jamie.Nelson@xxxxxxx>
  • To: <gptalk@xxxxxxxxxxxxx>
  • Date: Thu, 23 Oct 2008 19:15:50 -0500

If you’re using a character class like that, then yes, it is case sensitive.

 

Since you’re writing filters to check whether a machine is a laptop or desktop, 
you might take a look at list member Jakob Heidelberg’s blog about the perfect 
WMI filter for this. He recently had a contest to see who could come up with 
one and the winner took home a copy of SDM Software’s GPExpert Troubleshooting 
Pak.

 

Here’s Jakob’s blog: 
http://heidelbergit.blogspot.com/2008/02/wmi-filter-contest-are-you-knight-in.html

 

The winner ended up being this, which doesn’t depend on the computer name:

 

(Laptop) SELECT * FROM Win32_PhysicalMemory WHERE FormFactor = 12

(Desktop) SELECT * FROM Win32_PhysicalMemory WHERE FormFactor != 12

 

Regards,

 

Jamie Nelson | Operations Consultant | BI&T Infrastructure-Intel | Devon Energy 
Corporation | Work: 405.552.8054 | Mobile: 405.200.8088 | http://www.dvn.com 
<http://www.dvn.com/> 

 

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On 
Behalf Of Jerry Abouelnasr
Sent: Thursday, October 23, 2008 5:15 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] Re: GPO WMI/WQL Filter

 

I just tested it. That looks like it will do it. If you had any idea what I've 
put myself through, you would really know how thankful I am when I say thank 
you very much. :-)

 

I take it you put the lower cases in there because the query is case sensitive?

 

Jerry

On Thu, Oct 23, 2008 at 3:04 PM, Nelson, Jamie <Jamie.Nelson@xxxxxxx> wrote:

The way you are filtering on the name though, you're only saying the last 
character cannot be L or T. This is different than saying the last 2 characters 
can't be LT.

 

Try this and see if it helps:

 

Select * From Win32_ComputerSystem Where Name Like "%[^Ll][^Tt]"

 

Jamie Nelson | Operations Consultant | BI&T Infrastructure-Intel | Devon Energy 
Corporation | Work: 405.552.8054 | Mobile: 405.200.8088 | http://www.dvn.com 
<http://www.dvn.com/> 

 

From: gptalk-bounce@xxxxxxxxxxxxx [mailto:gptalk-bounce@xxxxxxxxxxxxx] On 
Behalf Of Jerry Abouelnasr
Sent: Thursday, October 23, 2008 4:56 PM
To: gptalk@xxxxxxxxxxxxx
Subject: [gptalk] GPO WMI/WQL Filter

 

Hi everyone

I'm trying to filter a GPO using a WMI query. My goal is to have one policy 
only apply to desktops and one only apply to laptops. I understand that there 
is currently no really good method of doing this by querying hardware (and that 
a contest exists) :-). Fortunately, our naming standard appears to accomodate. 
All laptops end with "LT."

So, when I run a query for Select * From Win32_ComputerSystem Where Name Like 
"%LT"    ----  I get the desired result when I log in to a laptop with a name 
ending in LT. The policy applies. When I log into a computer that does not end 
with LT, the GPO is filtered out and denied. 

Now - to do the opposite, I'm having problems. I want to filter based on 
computers NOT named "%LT" - My goal in doing so is to have a policy ONLY apply 
to workstations (which do not end with LT in their name) --- So, I have tried: 
Select * From Win32_ComputerSystem Where Name Like "%[^LT]" ---- This works for 
me on Vista, but not on Windows XP SP2 workstations. When testing from a 
command prompt - on a workstation not ending with LT - I am able to validate 
that the "%[^LT]" exclusion is not working on XP workstations vs. it working on 
a Vista workstation using  the following command: wmic path 
win32_ComputerSystem WHERE (Name like "%[^LT]") get Name. 

So, it feels like I'm in the right neighborhood. I suspect that the Syntax 
might need to be different on XP, but I've already tried variations to no avail.

Any help would be greatly appreciated. 

Thanks

Jerry

________________________________

Confidentiality Warning: This message and any attachments are intended only for 
the use of the intended recipient(s), are confidential, and may be privileged. 
If you are not the intended recipient, you are hereby notified that any review, 
retransmission, conversion to hard copy, copying, circulation or other use of 
all or any portion of this message and any attachments is strictly prohibited. 
If you are not the intended recipient, please notify the sender immediately by 
return e-mail, and delete this message and any attachments from your system. 

 

Other related posts: