powershellpowershell-v5.1

Interactively kill process using powershell


How can an interactive method for killing process in powershell be created?

Kill process preferably in a form using input field to find and kill the processes desired.


Solution

  • This is the best I could come up with

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
    $killme = [Microsoft.VisualBasic.Interaction]::InputBox('Enter complete or portion of process name', 'Process Name', "")
    
    
    Get-Process  | Where-Object ProcessName -Like "*$killme*" | kill -confirm -Force -PassThru