Command referenceInvoke-WebRequest
Invoke-WebRequest command (Windows / PowerShell)
What it does
Send HTTP and HTTPS requests and return response metadata and content. Guides covering the invoke-webrequest powershell usually need pipeline-friendly examples, common parameters, and how the cmdlet compares with classic CMD or Linux tools. This page includes syntax, options, and copyable PowerShell examples.
Send HTTP and HTTPS requests and return response metadata and content.
Syntax
Invoke-WebRequest [-Uri] <Uri> [-Method <WebRequestMethod>] [-Headers <IDictionary>] [-Body <Object>] [-OutFile <String>]
Common options
| Flag / option | Meaning |
|---|---|
| -Uri | Set the request address. |
| -Method | Choose GET, POST, PUT, or another method. |
| -Headers | Supply request headers as a dictionary. |
| -Body | Provide request content. |
| -OutFile | Write response content to a file. |
Practical examples
Fetch page
Invoke-WebRequest -Uri https://example.com
Returns a web response object.
Download file
Invoke-WebRequest https://example.com/app.zip -OutFile app.zip
Saves response bytes to app.zip.
Post JSON
Invoke-WebRequest https://api.example.com/events -Method Post -ContentType 'application/json' -Body '{"ok":true}'Posts a JSON body.
Linux ↔ Windows equivalent
Closest match: curl (Linux / bash / sh / zsh). Transfer data to or from URLs using many network protocols.
Common mistakes
- Assuming the `curl` alias has native curl's argument syntax in Windows PowerShell.
- Embedding tokens in scripts or shell history instead of protected secret storage.
Related commands
- Get-ContentRead file content or provider data as a stream of objects.
- Get-NetIPAddressRetrieve IP address configuration from Windows network interfaces.
- curlTransfer data to or from URLs using many network protocols.
- ipconfigDisplay and manage Windows IP configuration and DNS client state.
- pingTest reachability and measure response time with ICMP echo requests.
- sshOpen a secure remote shell or run a command over SSH.
- pingTest IP reachability and measure round-trip response time.
- netstatDisplay active connections, listening ports, routing data, and protocol statistics.
FAQ
What does Invoke-WebRequest do in PowerShell?
Send HTTP and HTTPS requests and return response metadata and content.
How can I see examples for Invoke-WebRequest?
Run `Get-Help Invoke-WebRequest -Examples`, then adapt an example to the provider and objects you are using.
What is a practical Invoke-WebRequest example?
Try `Invoke-WebRequest -Uri https://example.com` — Returns a web response object.
Does Invoke-WebRequest return text or objects?
Invoke-WebRequest normally participates in PowerShell's object pipeline; formatting seen in the console is a view of those objects.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.