Search code examples
powershelliisappcmdweb-administration

list redirect destinations (URL) IIS sites


I have several redirect sites configured in IIS 8.5, and I want to list them all. I've tried:

.\appcmd.exe list site * -section:system.webServer/httpRedirect

but wildcards are not working fine with appcmd. I also tried from the WebAdministration module:

Get-WebConfiguration system.webServer/httpRedirect * | Get-Member destination

but this is also not delivering what I need... which is a list with 2 columns for site & destination


Solution

  • This snippet will give you the sitenames and httpredirect destinations :

    Get-Website | select name,@{name='destination';e={(Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name "destination" -PSPath "IIS:\Sites\$($_.name)").value}}
    

    For fetching just the destinations:

    (Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name "destination" -PSPath 'IIS:\Sites\*').value