How do I enumerate IIS websites using Powershell and find the app pool for each?

前端 未结 3 2174
死守一世寂寞
死守一世寂寞 2021-02-19 20:02

I can search for websites using:

Get-WmiObject -Namespace \"root\\WebAdministration\" -Class Site -Authentication PacketPrivacy -ComputerName $servers

3条回答
  •  甜味超标
    2021-02-19 20:35

    Use the webadministration module:

    Import-Module WebAdministration
    
    dir IIS:\Sites # Lists all sites
    dir IIS:\AppPools # Lists all app pools and applications
    
    
    # List all sites, applications and appPools
    
    dir IIS:\Sites | ForEach-Object {
    
        # Web site name
        $_.Name
    
        # Site's app pool
        $_.applicationPool
    
        # Any web applications on the site + their app pools
        Get-WebApplication -Site $_.Name
    }
    

提交回复
热议问题