Iis – How to list which application pool each IIS6 Website is using

iisiis-6windows-server-2003

I would like to audit the application pools on an IIS6 server, I want to check which websites relate to each application pool and the .NET version they are running. How can I do this without manually going though the interface and looking at each one in turn?

Best Answer

Use iisapp.vbs to list app pools:

iisapp.vbs 

Unfortunately, unlike in IIS7, the app pools have no idea which .NET version they are running, they are just loading the filter requested by the site, so you have to iterate through the sites and pull the info. This StackOverflow answer has a suggested script for walking the web sites and listing their app pool and .NET versions.

(Script credit to @Kev at StackOverflow)

# Walk sites
$allsites = ([adsi]"IIS://Localhost/W3SVC").children | where { $_.SchemaClassName -eq "IIsWebServer" }
$pools = @()

foreach($site in $allsites)
{
  $path = "IIS://Localhost/W3SVC/" + $site.Name + "/root"
  $siteRoot = [adsi]$path
  $sitePool = $siteRoot.AppPoolId

  $aspx = $siteRoot.ScriptMaps | where { $_.StartsWith(".aspx") }

  if( $aspx.Contains("v1.1")) {
    $runtime = "1.1"
  } elseif ($aspx.Contains("v2.0")) {
    $runtime = "2.0"
  } elseif( $aspx.Contains("v4.0")) {
    $runtime = "4.0"
  } else {
    $runtime = "Unknown"
  }

  $v =  @{AppPool = $siteRoot.AppPoolId; RunTime = $runtime; SiteId = $site.Name}
  $pools += $v
}

$pools | Sort-Object { $_.AppPool } | % { Write-Host $_.AppPool $_.SiteId $_.RunTime }