Skip to content

Instantly share code, notes, and snippets.

@michaellwest
Created July 25, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaellwest/27fada34020ae39e0614 to your computer and use it in GitHub Desktop.
Save michaellwest/27fada34020ae39e0614 to your computer and use it in GitHub Desktop.
The following lists all application pools in IIS and matches with their associated w3wp.exe process id.
Import-Module -Name WebAdministration
$appPoolsPath = "IIS:\AppPools"
foreach($appPool in Get-ChildItem -Path $appPoolsPath) {
if($appPool.state -eq "Started") {
$processes = Get-ChildItem -Path "$($appPoolsPath)\$($appPool.Name)\WorkerProcesses"
foreach($process in $processes) {
[pscustomobject]@{
"AppPool" = $appPool.Name
"ProcessId" = $process.ProcessId
"State" = $process.State
"StartTime" = $process.StartTime
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment