windowspowershellprocess

How can I forcibly kill a process using powershell?


I have a process I'd like to kill:

$ ps Sourcetree

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   1311     116   136720     137804      57.45   1044   1 SourceTree

Send it to Stop-Process, aka kill:

$ ps Sourcetree | kill

Runs without error. But the process isn't killed:

$ ps Sourcetree

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
   1311     116   136720     137804      57.45   1044   1 SourceTree

How can I forcibly kill a process using powershell?


Solution

  • The simplest correct answer is:

    Get-Process SourceTree | Stop-Process -Force
    

    "SourceTree" is a process name.