PowerShell for Windows Admins

Jan 16 2014   1:58PM GMT

Win32_Process examples–terminate process

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

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

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: