PSVersion 7.4.6 FIND: if (@($procs | ? {$_.ProcessId -ne 4242 -and $_.Path -and $_.Path.StartsWith('C:\Users\me\AppData\Local\Programs\T3 Code', 'CurrentCultureIgnoreCase')}).Count -gt 0) { exit 0 } else { exit 1 } KILL: $procs | ? {$_.ProcessId -ne 4242 -and $_.Path -and $_.Path.StartsWith('C:\Users\me\AppData\Local\Programs\T3 Code', 'CurrentCultureIgnoreCase')} | % { Write-Output $_.ProcessId } --- zero matches count=0 FIND exit=1 KILL would stop PIDs: [] --- one match = own pid (in-place uninstaller) count=0 FIND exit=1 KILL would stop PIDs: [] --- one other match (leftover app) count=1 FIND exit=0 KILL would stop PIDs: [5001] --- two other matches count=2 FIND exit=0 KILL would stop PIDs: [5001,5002]