Get Running Process Owners

by Jul 2, 2010

If you need to filter running processes by owner, for example to terminate the ones owned by some user, you should use WMI and the GetOwner() method. This code will retrieve all processes from a local or remote system and add an Owner property, which you can then use to select or filter processes:

Get-WmiObject Win32_Process |
ForEach-Object {
$ownerraw = $_.GetOwner$owner = '{0}{1}' -f $ownerraw.domain, $ownerraw.user$_ | Add-Member NoteProperty Owner $owner -PassThru
} |
Select-Object Name, Owner

Note that you can get owner information for other users only when you have admin privileges.