Solved

adding wmi code to group policy causes syntax error

Posted on 2008-10-29
5
888 Views
Last Modified: 2012-06-21
I'm trying to paste WMI code from Code Creator to a new group policy WMI filter but getting error.

The error is, "A syntax error occurred trying to evaluate a query string".

With this code I want to filter for a machine that has the host name "guid-03" so that I can prevent a policy from being applied. The machine is a thin client that doesn't show up in AD so I need to use WMI filtering to apply the GP.

thanks
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
    "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE DNSHostName = 'guid-03'",,48) 
For Each objItem in colItems 
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "Win32_NetworkAdapterConfiguration instance"
    Wscript.Echo "-----------------------------------"
    Wscript.Echo "DNSHostName: " & objItem.DNSHostName
Next

Open in new window

0
Comment
Question by:moomee2
  • 3
  • 2
5 Comments
 
LVL 41

Expert Comment

by:graye
ID: 22840250
You just need the one line:
SELECT * FROM Win32_NetworkAdapterConfiguration WHERE DNSHostName = 'guid-03'
0
 

Author Comment

by:moomee2
ID: 22841340
still get same error. image attached
syntax-error.jpg
0
 
LVL 41

Expert Comment

by:graye
ID: 22842302
Hang on... I mean, just that ONE line... not any other lines at all
0
 

Author Comment

by:moomee2
ID: 22845759
i tried that too...same error
0
 
LVL 41

Accepted Solution

by:
graye earned 500 total points
ID: 22846212
Are you sure?   I promise that just the one line should be the solution
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question