Powershell: IIS Application Pool Killer
Every now and then IIS application pools lock up and needs to be killed. You can add the field PID in Task Manager and then use cmd tools to find which one of the IIS Worker Process is the right one and kill it. I created a simple script that lists all the IIS Application Pools by name, select the one you need to kill and the script kills it. The script is available on my Github and is named IISAppPoolKiller.ps1. Please comment below what you have been using this for!
Short break down of the script it self. First we load the modules needed.
Then we list all the application pools and pipe that to a gridview. When you select one in the gridview we pipe that to a variable.
dir IIS:AppPools | Out-GridView -Title ‘Select apppool to restart’ -PassThru | Set-Variable -Name selectedAppPool
With the selected application pool we loop all the worker processes running and kill them.
foreach($worker in $selectedAppPool.workerProcesses.Collection)