Terminating a running process is simply a case of calling the Terminate method:
function remove-proc{
[CmdletBinding()]
param (
[string]$computername = $env:COMPUTERNAME,
[string]$processname
)
Get-CimInstance -ClassName Win32_Process -ComputerName $computername -Filter “Name = ‘$processname'” |
Invoke-CimMethod -MethodName Terminate
}
This will terminate all instances of a given process. If you want to be more selective then change the function to use the process id rather than the process name