Hello all, I'm a PowerShell newbie -- trying to leverage the technology at my company. I got a question about an issue I hit and I wanted to see if anyone have an idea on how I can solve it.
Statement of Work: I have got a database full of URL redirects that I need to test (for example, I will connect to the old URL http://www.mycompany.com/support/test.page and our web site will redirect to http://www.mycompany.com/newsupport/newpage.html . Since the list is long and I want to continue to build my PowerShell skills, I want to use PowerShell to test each redirect.
Issue: I can use PowerShell to retrieve a single web page and read the wewb page, have flow control, and that (Thanks PowerShell in Action Book!). What I can't figure out if there is a way to capture the new URL. For example, the steps I want to take:
- connect to the URL in the database using .NET System.Net.WebClient.DownloadString and dump into variable. For example, I call www.xyz.com/support/page1.html but a URL redirect happens and I am now on www.xyz.com/techsupport/page2.html, how can I retrieve the newly redirected URL? Would it be in my variable object? if so, whats its name? I tried browsing MSDN but I cannot seem to locate it (I'm hopefully that it exists).
If somebody could provide syntax on how I can retrieve that newly redirected URL, that would be great. Please keep in mind, I'm a newbie... if you could provide the answer as speaking to a beginner
, that would be great. Thanks in advance for your response.