Skip to content

Instantly share code, notes, and snippets.

@christian-korneck
Created August 8, 2018 20:44
Show Gist options
  • Save christian-korneck/4d00cd6fb0048f4cdefe189ba89d175e to your computer and use it in GitHub Desktop.
Save christian-korneck/4d00cd6fb0048f4cdefe189ba89d175e to your computer and use it in GitHub Desktop.
powershell - process list with username
#$proclist = get-wmiobject -Class win32_process | select -last 50
$proclist = get-wmiobject -Class win32_process
foreach ($proc in $proclist) {
$userinfo = Invoke-WmiMethod -InputObject $proc -Name GetOwner
$userstring = "$($userinfo.Domain)\$($userinfo.User)"
if ($userstring -eq "\") {$userstring = ""}
Add-Member -InputObject $proc -Name User -Value $userstring -MemberType NoteProperty
}
$proclist | select ProcessId, User, name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment