Solved

adding wmi code to group policy causes syntax error

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
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.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

862 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

21 Experts available now in Live!

Get 1:1 Help Now