Hackviking He killed Chuck Norris, he ruled dancing so he took up a new hobby…

8Jan/180

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.

Import-Module ServerManager
Add-WindowsFeature Web-Scripting-Tools
Import-Module WebAdministration

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)
{
    Stop-Process $worker.processId
}
Comments (0) Trackbacks (0)

No comments yet.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

No trackbacks yet.