0

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.

skrap3e
  • 143
  • 1
  • 1
  • 8
  • 1
    you can use `Get-Process` to get the list of processes, filter out any that you want to hide, feed the remaining items to `Out-Gridview` with `-OutputMode Single` and a useful msg to the user, and - finally - use the output from that to kill the process. [*grin*] – Lee_Dailey Jun 24 '19 at 23:39
  • there is no way on ogv to kill the process from that point – skrap3e Jun 25 '19 at 14:51
  • um, er, what? [*grin*] the output of the O-GV call will be one item that can be used with the desired next cmdlet - such as `Stop-Process`. – Lee_Dailey Jun 25 '19 at 15:17
  • i created that script as you suggested and while it does kill a process, selecting the process is not an interactive procedure and so it doesn't address the actual question. – skrap3e Jun 25 '19 at 15:32
  • your definition is apparently very different from mine. [*grin*] my method presents a list, allows one to choose one item, and then stops it. that seems to be interactive to me ... – Lee_Dailey Jun 25 '19 at 15:38

1 Answers1

0

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
skrap3e
  • 143
  • 1
  • 1
  • 8