SOLVED: Find web sites and applications using a Microsoft IIS server application pool using the IISAdministration PowerShell cmdlets

If you're using the IISAdministration PowerShell module you may want to find out what applications are in use by an application pool.

(if you're using the older WebAdministration module I've written the solution here).


# Gets the names of the applications in the specified application pool.
Function Get-ApplicationPoolApplicationNames
{

    [CmdletBinding()]
    param(

        [Parameter()]
        [System.Object] $ApplicationPoolName
    )
    process
    {

        $applicationNames = New-Object System.Collections.Generic.List``1[System.String];
        $webSites = Get-IISSite;
        foreach ($webSite in $webSites)
        {    
            foreach ($application in $webSite.Applications)
            {
                if ($application.ApplicationPoolName -eq $ApplicationPoolName)
                {
                    if ($application.Path -eq "/")
                    {
                        $applicationNames.Add($webSite.Name);
                        continue;
                    }
                    $applicationNames.Add("$($webSite.Name)$($application.Path)");
                }    

            }
        }
        return $applicationNames;
    }


The results are returned in the format


SiteName

or

SiteName\ApplicationName


Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations