Win32_Process examples–terminate process

Terminating a running process is simply a case of calling the Terminate method:

function remove-proc{
param (
[string]$computername = $env:COMPUTERNAME,

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

2 Responses to Win32_Process examples–terminate process

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>