PowerShell: Manage Process by GUI

Here is a short little PowerShell GUI that I created that will kill a selected process. It uses the

Out-GridView

to list the processes. By selecting inside the

Out-Gridview

we kill that process. The goal of this small GUI is to create a larger program with multiple functions.

Function ManageProcess{
$Process=Get-Process | Out-GridView -OutputMode Single
$GUI = new-object -comobject wscript.shell
if ($Process.processname -ne "$False"){
$ProcessName=$Process.processname
$Yes_Cancle = $GUI.popup("Do you want to kill $ProcessName ?", `
0,"Manage Process",3)
If ($Yes_Cancle -eq 6) {
Stop-Process -processname $ProcessName
$GUI.popup("$ProcessName has been killed as soon as you hit OK")
cls
}
else {
$GUI.popup("You decided to cancel. $ProcessName will not be killed")
cls
}}}
cls
ManageProcess
Advertisements