Script to Kill Processes by Command Line Arguments

Quote from moshe on 20/10/2020, 7:39 amProblem
- Processes in the Task Manager that are obsolete and need to be terminated.
- Auto corrective action to kill stuck / freeze processes
Solution
In the example below, we have a lot of nodeJS processes weren’t terminated:
List all processes node running Server.js task
Get-WmiObject win32_process | where commandline -Like ‘node ./Server.js task*’ | Select-Object ProcessId
Validate the list and run this command to terminate
Get-WmiObject win32_process | where commandline -Like ‘node ./gulp.js task*’ | remove-wmiobject
Problem
- Processes in the Task Manager that are obsolete and need to be terminated.
- Auto corrective action to kill stuck / freeze processes
Solution
In the example below, we have a lot of nodeJS processes weren’t terminated:
List all processes node running Server.js task
Get-WmiObject win32_process | where commandline -Like ‘node ./Server.js task*’ | Select-Object ProcessId
Validate the list and run this command to terminate
Get-WmiObject win32_process | where commandline -Like ‘node ./gulp.js task*’ | remove-wmiobject