Solved

OR Statement in WMI Filter

Posted on 2013-01-30
3
1,135 Views
Last Modified: 2013-01-30
I currently have a WMI query that applies to all computers but a specific model.

Select * From Win32_ComputerSystem WHERE NOT Model LIKE "%Latitude D610%"

Open in new window


How can I change this for more than one model? For example, how can I exclude two or three other models in this same filter?
0
Comment
Question by:Joseph Moody
[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
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38835333
something like this?
Select * From Win32_ComputerSystem WHERE NOT Model LIKE "%Latitude D610%" AND NOT Model LIKE "%Latitude 2%"
AND NOT Model LIKE "%Latitude 3%"
AND NOT Model LIKE "%Latitude 4%"

Open in new window

0
 
LVL 22

Author Closing Comment

by:Joseph Moody
ID: 38835368
Great!

I was doing OR and not AND. Thank you.
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38835371
use ExecQuery to run dynamic sql query instead of concatenate hardcoded all the models:
dim query = "Select * From Win32_ComputerSystem WHERE"
modelsArray = Array("Latitude D610", "Latitude D2", "Latitude D3")
For Each model In modelsArray
  query = query & " AND NOT Model LIKE ""%" & model & "%""
Next

query = Replace(query ,"WHERE AND","WHERE")

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery(query)

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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