List IIS AppPools and their associated Process Ids with PowerShell - arcdev/engram404 GitHub Wiki
originally posted 2017-04-22 at https://engram404.net/list-iis-apppools-and-their-associated-process-ids-with-powershell/
When doing ASP.NET development chances are you have quite a few AppPools running.
Last I checked there was no way within IIS Manager to see what actual process ids (w3wp.exe) are associated with any given AppPool.
And mostly we don't care.
But, occasionally you have a need to know (e.g. for debugging or seeing memory or CPU usage).
Thus, here's a quick PowerShell script to list just that:
Import-Module WebAdministration
dir "IIS:\AppPools" | % {dir "IIS:\AppPools\$($_.name)\WorkerProcesses"} | select processId, appPoolName | format-table -AutoSize
The output will look something like this:
processId appPoolName
--------- -----------
20428 DefaultAppPool
57348 AnotherAppPool
4286 ASP.NET
Note: I've never tried this with multiple worker processes associated with a single AppPool.