Untitled

 avatar
unknown
plain_text
2 years ago
1.0 kB
5
Indexable
# Import the IIS module
Import-Module WebAdministration

# Get the list of sites in IIS
$sites = Get-ChildItem -Path "IIS:\Sites"

# Iterate over each site
foreach ($site in $sites) {
    $siteName = $site.Name

    # Get the web configuration for the site
    $configPath = "IIS:\Sites\$siteName"
    $config = Get-WebConfiguration -PSPath $configPath

    # Get the 'system.webServer/httpProtocol/customHeaders' section for the site
    $customHeadersPath = "system.webServer/httpProtocol/customHeaders"
    $customHeaders = $config | Get-WebConfigurationProperty -PSPath $configPath -Filter $customHeadersPath

    # Check if response headers exist
    if ($customHeaders.Collection) {
        Write-Host "Site: $siteName"

        # Iterate over each response header configuration
        foreach ($header in $customHeaders.Collection) {
            $headerName = $header.name
            $headerValue = $header.value

            Write-Host " - Response Header: $headerName $headerValue"
        }

        Write-Host
    }
}
Editor is loading...