Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WMI Scripting 1

Status
Not open for further replies.

AgedMcse

MIS
Sep 3, 2003
2
0
0
GB
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.
 
I have answered your question in javascript forum, if you're using jscript flavor.
 
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.
 
Thank you Tsuji for your prompt and comprehensive explanation. It is really appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top