Friday, October 8, 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

0 comments:

Post a Comment