Solved

adding wmi code to group policy causes syntax error

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now