Search code examples
powershellrds

Check page redirects via PowerShell


I'm working on RDWeb access solution and wanted to check that the RDS hosts when typed in an Internet Explorer page redirect to https://rds.ca.org/rdweb

For example I wanted to check via a PowerShell script if I type srdshost01 or 02 or 03 or 04 in an IE page it should get me the redirected link.


Solution

  • You could post an HttpWebRequest to the URL using the alternative host name and check wether the response was sent from the redirected URL:

    $response = [System.Net.WebRequest]::Create("http://srdshost01").GetResponse()
    $isRedirected = $response.ResponseUri -eq "https://rds.ca.org/rdweb"