INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

WMI Scripting

WMI Scripting

(OP)
I am grateful for the tips given in the forum relating to WMI scripting and have used them to good effect.

The first question relates to a WMI filter which should exclude computers from processing a group policy object.
I created the following but it filtered out the opposite ie computers that matched the computer name were included and others which didn't were excluded.
Select * From Win32_ComputerSystem Where Name  LIKE 'BX-BAT%'

I overcame the problem by using the following which works fine but cannot understand why.

Select * From Win32_ComputerSystem Where Not Name  LIKE 'BX-BAT%'

The second question is now that I have got the script working how can I add further strings relating to Win32_ComputerSystem in order to include/exclude additional computer names BX-TRM% WD-TRM%

Thanks in advance.  

RE: WMI Scripting

I have answered your question in javascript forum, if you're using jscript flavor.

RE: WMI Scripting

This is what I posted to javascript: the thread is deleted.

[1] Select * From Win32_ComputerSystem Where Name  LIKE 'BX-BAT%'
Will bind to win32_computersystem instances of name property which looks like these, for instance:
    BX-BAT
    BX-BATXYZ
    BX-BATABC
    etc...

[2] Select * From Win32_ComputerSystem Where Not Name  LIKE 'BX-BAT%'
Will bind to win32_computersystem instances of name property which looks like these, for instance:
    ABC
    BX-TABXYZ
    XYZABC
    etc...

[3] Select * From Win32_ComputerSystem Where ((Name  LIKE 'BX-BAT%') Or (Name Like 'BX-TRM%'))
Will bind to win32_computersystem instances of name property which looks like these, for instance:
    BX-BAT
    BX-BATXYZ
    BX-BATABCDEF
    BX-TRM
    BX-TRMXYZ
    BX-TRMABCDEF
    etc...

[4] Select * From Win32_ComputerSystem Where ((Name  LIKE 'BX-BAT%') Or (Name Like 'BX-TRM%') Or (Name Like 'WD-TRM%'))
Will bind to win32_computersystem instances of name property which looks like these, for instance:
    BX-BAT
    BX-BATXYZ
    BX-BATABCDEF
    BX-TRM
    BX-TRMXYZ
    BX-TRMABCDEF
    WD-TRM
    WD-TRMXYZ
    WD-TRMABCDEF
    etc...

[5] The rest you can combine boolean like any sql statement Not(<expression>) And (<expression>) Or (<expression>) with all the expressions evaluated to boolean understood. Nothing special really.  

RE: WMI Scripting

(OP)
Thank you Tsuji for your prompt and comprehensive explanation. It is really appreciated.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close