Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Get-Process: Add a switch that limits retrieval to the current user's own processes #21301

Copy link
Copy link
@mklement0

Description

@mklement0
Issue body actions

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 cmd

It 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)
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-DeclinedThe proposed feature is declined.The proposed feature is declined.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.