Monthly Archive


WMI LIKEs Wildcards

You may hear or read that WMI can’t accept wildcards. WRONG

WMI accepts wildcards but not the ones you might expect.



Get-Process p*

This gets all the process that begin with the letter p

To do something similar with WMI we need to use the –Filter parameter. We can get a single process like this

Get-WmiObject -Class Win32_Process -Filter "Name='powershell.exe'"

so you may want to try this

Get-WmiObject -Class Win32_Process -Filter "Name='p*'"


Oops no returns of any kind.

That’s because in the filter we are using WQL which uses the SQL wildcards

% = *   multiple characters

_ = ?    single character


OK then this will work

Get-WmiObject -Class Win32_Process -Filter "Name='p%'"


Oh no it won’t because a further complication is that we have to use the WQL LIKE operator not =

Get-WmiObject -Class Win32_Process -Filter "Name LIKE 'p%'"

And we have a winner


To use the single character wildcard (which in my experience doesn’t get used as much as the multi-character)

Get-WmiObject -Class Win32_Process -Filter "Name LIKE 'powershell.e_e'"


And as an added bonus the title of the post give us a way to remember to use the LIKE operator.

2 Responses to WMI LIKEs Wildcards

Leave a Reply