Add a -Tree or -Recurse parameter to Stop-Process
See original GitHub issueWhen 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:
- Created 3 years ago
- Reactions:2
- Comments:14 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think
-Recurse
aligns better with current terminology (cf. file system provider).My preference would be
-IncludeChildProcesses
as it’s descriptive for non-technical folks, but we can alias it to-Recurse