-1

I have to do some powershell script modifications which I cannot test properly on my dev machine.

Thats why I would like to know, if I can use an OR-Operator in my Get-WmiObject -filter operation?

Currently we use

(Get-WmiObject -Class Win32_Product -Filter "Name like 'ApplicationName1 Client%'" ...).Uninstall()

But lately we renamed the name of the application from ApplicationName1 to NewName. Thats why I would like to add another condition like this:

(Get-WmiObject -Class Win32_Product -Filter "Name like 'ApplicationName1 Client%' OR Name like 'NewName Client%'" ...).Uninstall()

My question would be:

Is this a valid syntax for the filter or would this throw an exception / give an error? If it gives an error, how would you do this?

4

1 回答 1

4

是的,这是有效的语法

例如

Get-WmiObject -Class win32_product -filter "Name Like 'citrix%' OR name like 'Microsoft%'"

会给每一个以 Citrix 开头的产品和每一个以 Microsoft 开头的产品

于 2016-04-26T10:18:27.947 回答