Skip to content

Add -Parent Parameter to Get-Process  #27029

@kilasuit

Description

Summary of the new feature / enhancement

Tools like Process Explorer show you a Tree like view for processes that allow you to visibly see a parent's process

I feel it makes sense to add -Parent and for this to run up the tree of parent processes & return information on all parent processes

We already expose Parent as a CodeProperty on the System.Diagnostics.Process type that we could use when returning a single parent process

We could extend this so that it recursively returns or add a similar Parents Code method that does this - but only if there are multiple parents & be blank if there aren't more than one.

This is doable already today but is messy & requires upfront knowledge of how many layers deep this process is.

(((gps | where {$_.Parent.id -eq $(gps -id $pid).Parent.Id}).parent).parent).parent

or simpler

(((gps -id $pid).Parent).parent).parent

Including this natively to this cmdlet would be a user experience win for any troubleshooting

Proposed technical implementation details (optional)

  • Add a parameter Parent for Get-Process
  • This should be contained a new Parent ParameterSet that when called will return info for Parent Processes of 1/more Processes but should require ID or Name or Current parameters (if Add -Current Parameter to Get-Process #27028 is added) as not to try and get all parent processes for all processes for performance reasons (unless deemed useful to do so)

Initial implementation should return just like how it is today for multiple processes, returning in sequence of grouping together the parent processes with the one being queried at that time for context reasoning

An ideal implementation would allow for this to be displayed in a tree view like those tools but would be a stretch goal & as such I would expect this to come much later on unless it would be simple to add

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesWG-NeedsReviewNeeds a review by the labeled Working Group

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions