Created
August 8, 2018 20:44
-
-
Save christian-korneck/4d00cd6fb0048f4cdefe189ba89d175e to your computer and use it in GitHub Desktop.
powershell - process list with username
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#$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