detect URL redirect

Welcome Forums General PowerShell Q&A detect URL redirect

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 7 years, 2 months ago.

  • Author
    Posts
  • #5875

    Member
    Points: 0
    Rank: Member

    by sege5641 at 2013-05-01 07:31:33

    What I need is a vary simple command that allows powershell to detect if the URL it has just opened has been redirected away from its set destination.

    Basically this is what I'm looking at:

    netsh interface ip set dns "wifi" static 192.0.0.0 primary
    ipconfig /flushdns
    Start-Process -FilePath "http://test.com"

    I want to open a different website if it gets redirected and doesn't land on the set website address.

    by DonJ at 2013-05-04 08:50:50

    Not the way you're doing it, no. You're starting a Web browser, and it is handling the redirect. You'd need to manually write a WebRequest object, since that would let you receive the redirect instruction yourself and decide what to do with it.

    by sege5641 at 2013-05-04 09:54:21

    Could I get some direction on how that would work?

    by DonJ at 2013-05-04 10:19:48

    That's *really* outside PowerShell. I'd suggest looking for a WebRequest tutorial, if you can find one, or asking at StackOverflow – this is .NET Framework programming, really. For example, http://stackoverflow.com/questions/2033 ... webrequest discusses turning off auto-redirect so you can handle it manually. You can do this in PowerShell, but it's all .NET code.

The topic ‘detect URL redirect’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort