TNT TNT - 11 months ago 76
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?


Use the MaximumRedirection parameter to prevent implicit redirects from occuring:

Invoke-WebRequest -MaximumRedirection 0