-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Summary of the new feature / enhancement
When retrieving processes - either with or without a -Name filter - it would be helpful to allow limiting the set of candidate processes to the current user's own processes, say with a newly introduced -CurrentUser (or -User) switch
# WISHFUL THINKING
# Only retrieve processes started with the current user identity.
Get-Process -CurrentUser
# Only retrieve `cmd` processes started with the current user identity.
Get-Process -CurrentUser -Name cmdIt is often only one's own processes that are of interest, especially when running non-elevated.
In non-elevated sessions, there's currently no easy way to determine which processes are one's own.
Update: One's own means: all processes running with the current user identity, irrespective of how they were started - see discussion in the next two comments.
Even in elevated sessions the solution is cumbersome:
Get-Process -IncludeUserName | Where UserName -eq $env:USERDOMAIN\$env:USERNAME
Proposed technical implementation details (optional)
Add the new switch only to the Name parameter set.
It would be the (possibly -Name-filtered) equivalent of the following, which on Windows can currently only be run with elevation:
#requires -RunAsAdministrator
Get-Process -IncludeUserName |
Where UserName -eq ($IsWindows ? "$env:USERDOMAIN\$env:USERNAME" : $env:USER)