Skip to content

Instantly share code, notes, and snippets.

@dkittell
Created December 14, 2015 13:38
Show Gist options
  • Save dkittell/90b53d1136d80f1c53c0 to your computer and use it in GitHub Desktop.
Save dkittell/90b53d1136d80f1c53c0 to your computer and use it in GitHub Desktop.
PowerShell – List Sites with App Pool
Import-Module WebAdministration
clear
$sites = @{Expression={$_.Name};Label="Site Name"}, ` @{Expression={$_.applicationPool};Label="Site App Pool";}, ` @{Expression={$_.PhysicalPath};Label="Site Physical Path";}
dir IIS:\Sites | Format-Table $sites -AutoSize
# List File Path for web.config files
ForEach($item in (dir IIS:\Sites))
{
write-host $item.Name
$filePath = $item.PhysicalPath
$fileName = "web.config"
Get-ChildItem -Recurse -Force $filePath -ErrorAction SilentlyContinue | Where-Object { ( $_.Name -like "*$fileName*") } | Select-Object FullName | format-Table * -AutoSize -HideTableHeaders
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment