How to Kill a Windows Process Remotely using PowerShell?

You may want to kill a Windows Process on a remote computer for many reasons. Thanks to PowerShell, this task can be performed easily using the Get-WmiObject cmdlet.

  • First, use the Get-WmiObject cmdlet to get the process
  • Next, use the “terminate()” function to kill the process.
$Processes = Get-WmiObject -Class Win32_Process -ComputerName $ComputerName -Filter "name='$ProcessName'"
foreach ($process in $processes) {
  $returnval = $process.terminate()
  $processid = $process.handle
  if($returnval.returnvalue -eq 0) {
    write-host "The process $ProcessName `($processid`) has been terminated successfully."
  } else {
    write-host "The process $ProcessName `($processid`) has not been terminated."

In order to use this script, save it as “Kill-RemotelyProcess.ps1” and run the following command:

PS > Kill-RemotelyProcess.ps1 -ComputerName <FQDN_Computer> -ProcessName <Name_of_the_process>


Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 279 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.