Solved

adding wmi code to group policy causes syntax error

Posted on 2008-10-29
5
905 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

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…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

717 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