This entry has been published on 2018-01-10 and may be out of date.
Last Updated on 2018-01-10.
[:en]Powershell’s Get-Process command lists the processes run by all users, which is not always useful, e.g. when running scripts for users with non-elevated rights.
Here is a workaround function:
#Alternative to Get-Process (get processes of all users) #This script gets only the processes run by the current user. function Get-UserProcess($ProcName) { $owners = @{} gwmi win32_process |% {$owners[$_.handle] = $_.getowner().user} $result = get-process | select processname,Id,@{l="Owner";e={$owners[$_.id.tostring()]}} | Where ({$_.Owner -eq $env:USERNAME -and $_.processname -eq $ProcName}) return $result } #Run it Get-UserProcess Explorer
[:]