Quantcast
Channel: WMI – PowerShell for Windows Admins
Viewing all articles
Browse latest Browse all 140

Win32_Process examples–terminate process

$
0
0

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


Viewing all articles
Browse latest Browse all 140

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>