Commands / Network

Invoke-WebRequest

Fetch a web page or file

intermediate Network Aliases iwrwgetcurl

Invoke-WebRequest
 Invoke-WebRequest -Uri 'https://example.com' -UseBasicParsing
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Invoke-WebRequest

Downloads a response. .Content is the body. .StatusCode is the status. On Windows PowerShell 5.1, add -UseBasicParsing to avoid old Internet Explorer parsing.

For JSON APIs, Invoke-RestMethod is usually nicer.

Downloads crawling along in Windows PowerShell 5.1? The progress bar is the cause. Turn it off for the session first:

$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri 'https://example.com/file.zip' -OutFile .\file.zip -UseBasicParsing

Try this

(Invoke-WebRequest -Uri 'https://example.com' -UseBasicParsing).StatusCode

Coming from another shell

ShellWhat you might type
bash / zshcurl -O https://example.com/file.zip
cmd.execurl.exe -O https://example.com/file.zip

More in From bash and From cmd.

Related commands