6

Is there a way to specify the -Filter parameter, using the WMI Query Language (WQL), of the Get-WmiObject cmdlet to filter based on the “Command Line” used to invoke the process? By “Command Line” I mean the “Command Line” that is shown in the Windows Task Manger, Process tab.

I want to get an array of process ids where the command line contains the string *Dev_SW*. I cannot use name because there are will be many process running with the same name that are not equal to the *Dev_SW* filter.

Matt
  • 45,022
  • 8
  • 78
  • 119
paulhr
  • 339
  • 4
  • 17

1 Answers1

6

Get-WMIObject will make the WMI call to the Class Win32_Process,

Then it will filter it where Command Line is like DEV_SW,

% is wild card in WMI

Get-WmiObject Win32_Process -filter "CommandLine LIKE '%Dev_SW%'"
ArcSet
  • 6,518
  • 1
  • 20
  • 34