Techibee.com

Easy way to kill processes on remote computer using powershell

I earlier authored https://techibee.com/powershell/kill-a-process-on-remote-machine-using-powershell-remoting/262 to demostrate how to kill a process on remote computer. Today when my colleague asked for it, I revisited this article again and felt we can do in much better and easy way.

Say if the computers are in a text file called comps.txt, the script follows like this.

$comps = Get-content c:tempcomps.txt

foreach ($comp in $comps) {

invoke-command -computer $comp { get-process notepad | stop-process -force}

}

In this example I am killing notepad process. You can replace the name with process you want to kill on remote computer.

Exit mobile version