Powershell script to collect a dump of a specific application pool

Procdump needs to be installed on the system. (procdump -i).


Import-Module WebAdministration
$apps = dir IIS:\AppPools\ | Select-Object -expand name
Write-host "Application Pools on this server:" -foregroundcolor red -backgroundcolor yellow
Write-Output $apps
$appname = Read-Host "Enter AppPool Name"
$apid = Get-WmiObject -NameSpace 'root\WebAdministration' -class 'WorkerProcess' -ComputerName 'LocalHost' | Where-Object {$_.AppPoolName -like "$appname"} | Select-Object -expand processId
procdump -ma -r $apid

First we import the webadmin module. Then list out the application pools on the server so you don’t need to open IIS or run appcmd list wps. Then it asks you for the name of the app pool which you can now copy and paste from the list provided. Then it finds the process ID and invokes procdump to take a full user dump with reflection (-r) to prevent the application pool from going down.

I did some very minor testing by just running apache bench on a site to create a bunch of requests and then running this script to see if it brings it down. All my requests were successful and my DotNetNuke site didn’t warm back up. I’m not 100% confident this is production safe, but at least it’s ready for testing.

Leave a Comment

Your email address will not be published.

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