question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a -Tree or -Recurse parameter to Stop-Process

See original GitHub issue

When using Stop-Process to terminate a process, a (very) common task is stop the entire tree of this process. To be more precise, ALL times when I need stop some process I need terminate the entire tree.

Currently the easiest way to do it is using taskkill: taskkill /IM "notepad.exe" /T /F obviously it is not a built in PowerShell Core feature. The PSCore command is Stop-Process, but it has not a built in way to kill the tree, then we need some pipeline-fu like here.

Then, by the same reason TaskKill has a /T flag, I propose Stop-Process get a -Tree -Recurse (as suggested by @GeeLaw) parameter. It is a natural addition, and surely it will avoid a lot of errors and extra boilerplate scripting for a so common task.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
GeeLawcommented, Mar 25, 2021

I think -Recurse aligns better with current terminology (cf. file system provider).

3reactions
SteveL-MSFTcommented, Jul 28, 2021

My preference would be -IncludeChildProcesses as it’s descriptive for non-technical folks, but we can alias it to -Recurse

Read more comments on GitHub >

github_iconTop Results From Across the Web

Terminate process tree in PowerShell given a process ID
If anyone landing here is looking for script to kill a process tree by specifying the name of the parent process, you can...
Read more >
Get-ChildItem - PowerShell
You can use the Recurse parameter to get items in all child containers and use the Depth parameter to limit the number of...
Read more >
PowerShell Basics: -Recurse Parameter with Get-ChildItem ...
PowerShell Scripting Basics: -Recurse parameter is used for persuading Get-ChildItem to search subdirectories. Including Code examples.
Read more >
Powershell script not deleting child items
Core\FileSystem::\[path to directory] has children and the Recurse parameter was not specified. In my PowerShell script I do have it specified.
Read more >
Pruning File Trees and Extending Cmdlets - Simple Talk
Step 1: Hooking up your filter · Step 2: Add your parameter(s) to the $introducedParameters list. · Step 3: Add your parameter(s) to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found