Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 931
  • Last Modified:

adding wmi code to group policy causes syntax error

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
moomee2
Asked:
moomee2
  • 3
  • 2
1 Solution
 
grayeCommented:
You just need the one line:
SELECT * FROM Win32_NetworkAdapterConfiguration WHERE DNSHostName = 'guid-03'
0
 
moomee2Author Commented:
still get same error. image attached
syntax-error.jpg
0
 
grayeCommented:
Hang on... I mean, just that ONE line... not any other lines at all
0
 
moomee2Author Commented:
i tried that too...same error
0
 
grayeCommented:
Are you sure?   I promise that just the one line should be the solution
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now