Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Faster WMI queries

451 views
Skip to first unread message

David Trimboli

unread,
Nov 28, 2012, 2:01:51 PM11/28/12
to
In theory, which WMI query should return objects fastest?

Get-WmiObject -Class Win32_Product |
Where-Object {$_.Name -match "EndNote"}

Get-WmiObject -Class Win32_Product -Filter "Name LIKE '%EndNote%'"

Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name LIKE
'%EndNote%'"

--
David Trimboli
http://www.trimboli.name/

nachu...@gmail.com

unread,
Dec 23, 2012, 10:31:33 AM12/23/12
to
Hello David!
First of all, the where-object is there to give you an option to filter through objects when there isn't a "-Filter" parameter.
the first option is the slowest - you bring all Win32_Product objects, pass them through the pipeline, and then select the ones that their name matches "EndNote"
the 2nd and 3rd option are faster, because filtering occur during the query, the WMI library return the objects that you asked for without you having to filter them with Where-Object.
0 new messages