Solved

adding wmi code to group policy causes syntax error

Posted on 2008-10-29
5
894 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

821 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