Friday, October 08, 2010

Taskmgr to PowerShell: Kill A Process

You know the drill, some app freezes. You try to close it, that doesn’t work.  You fire up taskmgr, sort by name, type in the name, and then hit the delete key to kill the process.  Easy with powershell:

Get-Process | ? {$_.Name -eq "firefox"} | kill

The real power here is the composability of powershell, for example you could also debug the process.

Get-Process | ? {$_.Name -eq "firefox"} | Debug-Process

Or if you’re not sure what’s going to happen you can always pass the –whatif qualifier:

PS C:\Users\igord\Downloads> Get-Process | ? {$_.Name -eq "firefox"} | Debug-Process -whatif
What if: Performing operation "Debug-Process" on Target "firefox (8204)"

Happy Powershelling

1 comment:

Cindy Dy said...

I enjoy reading your articles. You really have a wonderful blogs. Keep up the good work. Thank you also for the information!

www.gofastek.com