Hello,
I am new to powershell. I need a script to kill multiple instances of a process except for the most latest instance.
Just kill older instances but keep the latest instance running.
Any responses will be much appreciated.
Thanks!
Shaishav
Technology Tips and News
Hello,
I am new to powershell. I need a script to kill multiple instances of a process except for the most latest instance.
Just kill older instances but keep the latest instance running.
Any responses will be much appreciated.
Thanks!
Shaishav
The newest is the one with the highest process ID.
$newest=get-process svchost |sort id -desc|select -first 1
In theory:
1. Enumerate processes according to name vs PID
2. Retrieve the "age" of process instances
3. Kill instances until the "youngest one" is the last living process
M.
In theory:
1. Enumerate processes according to name vs PID
2. Retrieve the "age" of process instances
3. Kill instances until the "youngest one" is the last living process
M.