I can search for websites using:
Get-WmiObject -Namespace "root\WebAdministration" -Class Site -Authentication PacketPrivacy -ComputerName $servers
And I can list the app pools using:
Get-WmiObject -computer $servers -Namespace root\MicrosoftIISv2 -Class IIsApplicationPoolSetting -Impersonation Impersonate -Authentication PacketPrivacy
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.
Try the following:
The script above lists every site on the server and prints the root application pool name for each site.
Use the webadministration module:
Here's another option if you do not want to use the IIS:\ path.