Say you want to find all processes on a machine belonging to a particular user. This is the reverse of what we tried earlier – getting the owner of a particular process.
Here’s a one-liner to do that:
1 |
gwmi Win32_Process -ComputerName $computer | %{ if ($_.getowner().User -match "$user") { $_.ProcessName } } |
Of course replace $computer
and $user
appropriately.