title: How do I enumerate IIS websites using Powershell and find the app pool for each?
body: <p>I can search for websites using:</p>
  
  <pre><code>Get-WmiObject -Namespace "root\WebAdministration" -Class Site -Authentication PacketPrivacy -ComputerName $servers
  </code></pre>
  
  <p>And I can list the app pools using:</p>
  
  <pre><code>Get-WmiObject -computer $servers -Namespace root\MicrosoftIISv2 -Class IIsApplicationPoolSetting -Impersonation Impersonate -Authentication PacketPrivacy
  </code></pre>
  
  <p>How can I link these together to find which app pool is associated to which website? It's a Windows Server 2008 R2 server with IIS 7.5.</p>