Forum Discussion
dwaynek7
May 26, 2021Copper Contributor
can't get -NotMatch to work with win32_process
i have a script that looks at running processes for browser processes "firefox.exe" or "chrome.exe". but it doesnt seem to work. it detects that chrome and firefoxportable is not detected even though...
farismalaeb
Jun 03, 2021Iron Contributor
Dear
Yes, surely it wont be detected as running,
the object is $processlist is an array and you will need to go through objects in the array.
Also the array item contain multiple properties and one of them is Line
You can use the command as the following
$processlist=gwmi win32_process|select CommandLine|Select-String -Pattern chrome.exe,firefox.exe
$processlist.ForEach({If ($_.Line -like "*Google*"){write-output "Google is running"}
})