TNT TNT - 1 year ago 134
PowerShell Question

Is there really no way to prevent Invoke-WebRequest from following redirections

It seems the

cmdlet provides no way to inspect redirecting responses (by saying "don't follow redirections"). This would make the
-alias not only ridiculous but even more than superfluous.

Can anybody spare me this disappointment?

Answer Source

Use the MaximumRedirection parameter to prevent implicit redirects from occuring:

Invoke-WebRequest -MaximumRedirection 0
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download