For posterity, what was the final format of the filter?

From: [email protected] [mailto:[email protected]] On 
Behalf Of Michael Leone
Sent: Friday, October 3, 2014 1:36 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [NTSysADM] RE: [powershell] Get-WmiObject question on filtering

OK! So using the correct -Filter on the Get-WmiObject (as opposed to piping the 
output to a PS "Where" statement) cut down execution time from approx 52 
seconds to 40 seconds (which is approx 20%). Not too shabby ... maybe I can 
tweak the rest of the script ...

On Fri, Oct 3, 2014 at 12:57 PM, Michael Leone 
<[email protected]<mailto:[email protected]>> wrote:


On Fri, Oct 3, 2014 at 12:50 PM, Crawford, Scott 
<[email protected]<mailto:[email protected]>> wrote:
You need to escape the backslashes, like so:

Get-WmiObject -Class win32_process -Filter 
"ExecutablePath='c:\\windows\\system32\\calc.exe'"

AH. OK, I will try that. Thanks!



-----Original Message-----
From: [email protected]<mailto:[email protected]> 
[mailto:[email protected]<mailto:[email protected]>] 
On Behalf Of Michael Leone
Sent: Friday, October 3, 2014 11:25 AM
To: [email protected]<mailto:[email protected]>; 
[email protected]<mailto:[email protected]>
Subject: [powershell] Get-WmiObject question on filtering

I want to try a Get-WmiObject that uses a Filter for executable path.
But it's failing. If I filter for just the name of the exe I want, it works.  
And one of the properties returned is ExecutablePath

ExecutablePath             Property       string ExecutablePath {get;set;}

and that property gives me what I want:

C:\Windows\system32\calc.exe

So why can't I do this?

PS C:\Windows\system32> $a=(Get-WmiObject -Class win32_process -ComputerName 
"xxxx" -Filter
"ExecutablePath='C:\Windows\system32\calc.exe'")
$a

Get-WmiObject : Invalid query "select * from win32_process where 
ExecutablePath='C:\Windows\system32\calc.exe'"
At line:1 char:5
+ $a=(Get-WmiObject -Class win32_process -ComputerName "DCTRRDS003"
-Filter "Execu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-WmiObject],
ManagementException
    + FullyQualifiedErrorId :
GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1



================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to