Answered by:
WMI Filter on various computer names

Question
-
I am trying to create a WMI Filter for a GPO using Win32_ComputerSystem using Name to filter the results. The problem is when I try to add multiple values with Name I get a syntax error.
The statement looks like this
Select * From Win32_ComputerSystem where Name LIKE "ABCD%" or "EFGH%" or "IJKL%" AND Version like "6.%" or ProductType="3"
I get a syntax error when I tried to use the multiple Names. If I remove "EFGH%" and "IJKL%" it works fine. What am I missing?
Friday, February 10, 2012 6:37 PM
Answers
-
I'm thinking use commas for the like part so it reads
LIKE "ABCD%","EFGH%","IJKL%" AND Version
Or, using multiple likes
Name LIKE "ABCD%" OR Name LIKE "EFGH%" OR Name LIKE "IJKL%" AND Version
Sorry I don't have a machine to test on right now or I wouldn't be giving you so many experiments.
Hope this helps.
- Marked as answer by MarshawnMc Friday, February 10, 2012 8:33 PM
Friday, February 10, 2012 7:09 PM
All replies
-
Capitalize the ORs.Friday, February 10, 2012 6:44 PM
-
I capitalized the ORs and recieved an syntax error, so the WMI filter wasn't saved. Thoughts?Friday, February 10, 2012 6:52 PM
-
I'm thinking use commas for the like part so it reads
LIKE "ABCD%","EFGH%","IJKL%" AND Version
Or, using multiple likes
Name LIKE "ABCD%" OR Name LIKE "EFGH%" OR Name LIKE "IJKL%" AND Version
Sorry I don't have a machine to test on right now or I wouldn't be giving you so many experiments.
Hope this helps.
- Marked as answer by MarshawnMc Friday, February 10, 2012 8:33 PM
Friday, February 10, 2012 7:09 PM -
Capitalize the ORs.
Are you sure you don't want lowercase.
WQL IS NOT CASE SENSITIVE.
¯\_(ツ)_/¯
Friday, February 10, 2012 8:11 PM -
I am trying to create a WMI Filter for a GPO using Win32_ComputerSystem using Name to filter the results. The problem is when I try to add multiple values with Name I get a syntax error.
The statement looks like this
Select * From Win32_ComputerSystem where Name LIKE "ABCD%" or "EFGH%" or "IJKL%" AND Version like "6.%" or ProductType="3"
I get a syntax error when I tried to use the multiple Names. If I remove "EFGH%" and "IJKL%" it works fine. What am I missing?
This makes no sense.. Win32_COmputerSystem will only ever bring back one object. The name will always be the same as teh machine you are querying. This query cannot query multiple systems.
¯\_(ツ)_/¯
Friday, February 10, 2012 8:13 PM -
The second method work like a charm! Good job.
select * from Win32_ComputerSystem where Name like "ABC%" OR NAME like "DEF%" OR Name like "GHI%"
M.A.Mcleod
Friday, February 10, 2012 8:37 PM -
This is a WMI filter on a GPO, so sense each server runs the GPO locally if the filter equals true an application is installed. If the results of the filter are false the application isn't installed. This done since we have tons of servers in multiple OUs can I can't place the GPO against each OU. Hope this clears things up for you.
M.A.Mcleod
Friday, February 10, 2012 8:40 PM -
This is a WMI filter on a GPO, so sense each server runs the GPO locally if the filter equals true an application is installed. If the results of the filter are false the application isn't installed. This done since we have tons of servers in multiple OUs can I can't place the GPO against each OU. Hope this clears things up for you.
M.A.Mcleod
Thjat is the hard way to apply toi secific computers.
Use security group filtering. Add a goup the the security filtering property and add the computers to teh security group.
The WMI method may work but it is the slowest method as it has to actually contact the computer. SG filtering will skip any computer that is not in the group even before any GPO is applied. It is all server side. WMI is client/server.
GPO intends you to use security group filterin gin this case. It you wqanted one qaspect of a computer like total memory > 1Gb then you would have to use WMI filtering.
WMI filtering is a way of fine tuning GP that is really a last ditch effort.
¯\_(ツ)_/¯
Friday, February 10, 2012 9:16 PM -
Sounds strange that the construction "Select * From Win32_ComputerSystem where Name LIKE "ABCD%"AND Version like "6.%" or ProductType="3"" is working.
Im my view it is impossible, because class Win32_ComputerSystem does not contain keys Version and ProductType.
They are located in separate class Win32_OperatingSystem, thus we should use two separate select.
- Edited by Alexey N. Dmitriev Monday, June 17, 2019 2:13 PM
Monday, June 17, 2019 2:11 PM -
Sounds strange that the construction "Select * From Win32_ComputerSystem where Name LIKE "ABCD%"AND Version like "6.%" or ProductType="3"" is working.
Im my view it is impossible, because class Win32_ComputerSystem does not contain keys Version and ProductType.
They are located in separate class Win32_OperatingSystem, thus we should use two separate select.
Monday, July 13, 2020 10:25 AM