Add -Parent Parameter to Get-Process · Issue #27029 · PowerShell/PowerShell · GitHub
Skip to content

Add -Parent Parameter to Get-Process  #27029

Open

Description

@kilasuit

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

Activity

  1. added
    Issue-Enhancementthe issue is more of a feature request than a bug
    Needs-TriageThe issue is new and needs to be triaged by a work group.
    WG-Cmdletsgeneral cmdlet issues
    WG-NeedsReviewNeeds a review by the labeled Working Group
    on Mar 14, 2026
  2. MartinGC94 commented on Mar 14, 2026

    @MartinGC94
    Contributor

    You don't need to know the layers if you just use a loop:

    ($Process = Get-Process -Id $PID)
    while ($null -ne ($Process = $Process.Parent))
    {
        $Process
    }
    

    Or a longer version without the fancy assignment tricks that can be difficult to understand:

    $Process = Get-Process -Id $PID
    do
    {
        $Process
        $Process = $Process.Parent
    }
    while ($null -ne $Process)
    

    As for the feature suggestion itself, I don't see much use for it myself but it wouldn't bother me if it was added. However, if it were to be added I think it should be named something like "ParentTree" or something, because "Parent" to me would imply just 1 layer.

  3. changed the title [-]Add -Parent Parameter to Get-Process[/-] [+]Add -Parent Parameter to Get/Stop Process cmdlets[/+] on Mar 15, 2026
  4. changed the title [-]Add -Parent Parameter to Get/Stop Process cmdlets[/-] [+]Add -Parent Parameter to Get-Process [/+] on Mar 15, 2026
  5. rhubarb-geek-nz commented on Mar 15, 2026

    @rhubarb-geek-nz

    If there a cost overhead getting all the parents on Windows? Historically Windows has no concept of parent process and it is typically found using WMIC rather than a kernel API. On POSIX systems only the parent can wait for a child process to finish, on Windows any process that can get a handle for the process with the appropriate rights can wait. I can see this being done on Linux using the /proc file system but not how it would be done on MacOS or FreeBSD without having to run the 'ps' program.

  6. kilasuit commented on Mar 17, 2026

    @kilasuit
    CollaboratorAuthor

    From a search for the CodeMethod that Parent calls (GetParentProcess) I found this in the 6.0 Change log

    ## [6.0.0-alpha.12] - 2016-11-03
    - Fix GetParentProcess() to replace an expensive WMI query with Win32 API calls
    

    So should be reasonably fine in adding this.

  7. doctordns commented on Apr 17, 2026

    @doctordns
    Collaborator

    I'm not overly clear on the use case(s) for this proposed feature, but it seems a good idea.

    If there is no parent, or if the process itself IS the parent, would -parent , return a new error? And is that error a terminating or non-terminating error?

    Does -parent return the direct parent or the root of the process tree? I suspect it means the direct parent. Given this, is there a need for a -root to get the root of this process's process tree?

  8. moved this from Queue to In-Progress-Issues in Cmdlets Working Groupon Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions