rampengu
rampengu

Reputation: 51

Multiple wildcards in WMI query Powershell?

Our environment has been using a certain program for many years. Some clients are running latest version, some are running older versions, some are running VERY old versions... it's a mess and it is causing problems. I am trying to write a script to remove the old version and install the latest across the environment, but it is proving difficult so far because of all the different versions installed across the environment are all named slightly differently and have different IDs.

I am trying to return only the programs I am interested at this stage, will worry about the actual uninstalling afterwards. So far I have this:

Get-WmiObject -Class win32_product -Filter "Name like '%ExampleSoftware%'"

Which works great however some older versions appear as the equivalent of "Example Software" rather than "ExampleSoftware"... so what I need is to be able to do something like

Get-WmiObject -Class win32_product -Filter "Name like '%ExampleSoftware%' or '%Example Software%'"

Where am I going wrong? Many thanks for any help

Upvotes: 1

Views: 903

Answers (1)

Lieven Keersmaekers
Lieven Keersmaekers

Reputation: 58491

You need to add the column you want to match again

Get-WmiObject -Class win32_product -Filter "Name like '%ExampleSoftware%' or Name like'%Example Software%'"

Upvotes: 4

Related Questions