list redirect destinations (URL) IIS sites list redirect destinations (URL) IIS sites powershell powershell

list redirect destinations (URL) IIS sites


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


You can refer to below function to address this issue.

Function Get-IISRedirectURLs {     [CmdletBinding()]     Param     (         [Parameter(Mandatory=$false)][String]$SiteName     )     If ([String]::IsNullOrEmpty($SiteName)) {         Get-Website | ForEach-Object {             $SiteName = $_.Name             $prop = Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name 'destination' -PSPath "IIS:\Sites\$SiteName"             Write-Host "$SiteName`t$($prop.value)"         }     } Else {         $prop = Get-WebConfigurationProperty -filter /system.webServer/httpRedirect -name 'destination' -PSPath "IIS:\Sites\$SiteName"         Write-Host "$SiteName`t$($prop.value)"     } } 

For the complete sample archive, please download from How to list redirect destination URLs of IIS sites by PowerShell