Skip to main content

Command referenceInvoke-WebRequest

Invoke-WebRequest command (Windows / PowerShell)

WindowsPowerShellnetworkbeginner

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 / optionMeaning
-UriSet the request address.
-MethodChoose GET, POST, PUT, or another method.
-HeadersSupply request headers as a dictionary.
-BodyProvide request content.
-OutFileWrite 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.

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.