this script terminate a process running on a single or multiple servers using WMI
you input the process name as a screen input when you run the script , i didn't want to hardcode or pass it as an argument this to the script for security reasons

PowerShell
Edit|Remove
# ==============================================================================================
# 
# 
# 
# Script Name: Kill Process on multiple Computers
# 
# AUTHOR: Mohamed Garrana , 
# DATE  : 4/12/2010
# 
# COMMENT: 
# this script terminate a process running on a single or multiple servers using WMI
#you input the process name as a screen input when you run the script
# ==============================================================================================



function Terminate-Process {

	param(
	[Parameter(Mandatory=$true,valuefrompipeline=$true)]
	[string]$compname)
	begin {$processname = Read-Host "please Enter the process name to be terminated "}
	process {
 $result = Get-WmiObject -Class win32_Process -Filter "name='$processname'" -ComputerName $compname | ForEach-Object { $_.Terminate() }
 if ($result.ReturnValue -eq 0 ) 
 		{ Write-Output " $($processname) terminated on $($compname) "}
 	else { Write-Output "could not terminate $($processname) on $($compname) "}		
					
				}
end{Write-Output "Script ...END"}
}

#-----------------
# To terminate a process on multiple servers 
# get-content c:\servers.txt | Terminate-Process 
# servers.txt is a file of server name , each name on a separete line
#---------------------
#to terminate a process on a single server
# Terminate-process Server1 | tee-object c:\killprocesslog.txt
#you can use Tee-object to output results in a file and displaying on screen