It seems the Invoke-WebRequest
cmdlet provides no way to inspect redirecting responses (by saying "don't follow redirections"). This would make the curl
-alias not only ridiculous but even more than superfluous.
Can anybody spare me this disappointment?
By default, Invoke-WebRequest tries to use Internet Explorer (IE) to parse the HTML returned. This doesn’t work on systems without IE. To get around that, we can use the UseBasicParsing parameter to still download the content but only lightly parse it.
The Invoke-WebRequest cmdlet sends HTTP and HTTPS requests to a web page or web service. It parses the response and returns collections of links, images, and other significant HTML elements. This cmdlet was introduced in
The body is the content of the request that follows the headers. You can also pipe a body value to Invoke-WebRequest. The Body parameter can be used to specify a list of query parameters or specify the content of the response.
Beginning in PowerShell 7.0, Invoke-WebRequest supports proxy configuration defined by environment variables. See the Notes section of this article. Examples Example 1: Send a web request. This example uses the Invoke-WebRequest cmdlet to send a web request to the Bing.com site.
Use the MaximumRedirection
parameter to prevent implicit redirects from occuring:
Invoke-WebRequest http://www.google.com -MaximumRedirection 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With