I'm trying to add a filter or query to a line of PowerShell code, but I am getting weird results. I can replicate this problem using any WMI query. Here is an example:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -command "Get-WmiObject -class Win32_Processor -Namespace root\cimv2 -filter 'Status = `"OK`"'"
That gives me this error: Get-WmiObject : Invalid query "select * from Win32_Processor where Status = OK". But if I run it in a PowerShell window that is already open, like this:
Get-WmiObject -class Win32_Processor -Namespace root\cimv2 -filter 'Status = "OK"'
That works fine. So I am not understanding this behavior. I tried every manner of single quotes, double quotes, and escape characters, but nothing seems to work.
-Filter 'Name LIKE "Drivers - %"'