# PowerShell Invoke-WebRequest Proxy Setup

> Use a proxy in PowerShell: -Proxy and -ProxyCredential on Invoke-WebRequest and Invoke-RestMethod, one session per credential, a proxy for a whole window.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / PowerShell Invoke-WebRequest Proxy Setup

# How to use a proxy in PowerShell: Invoke-WebRequest, Invoke-RestMethod and curl.exe

Proxies · Nov 20, 2026 · 6 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![Using a proxy in Windows PowerShell in four steps: build a PSCredential with the proxy username and password, pass -Proxy and -ProxyCredential to Invoke-WebRequest or Invoke-RestMethod, set them once for the whole window with $PSDefaultParameterValues, then check the exit IP on ipinfo.io; the card notes http:// in -Proxy, the login in -ProxyCredential and curl.exe for SOCKS5.](https://quanticdata.io/blog/powershell-proxy-setup/hero.webp?v=20261120h)

On this page

- [What you need](https://quanticdata.io/blog/powershell-proxy-setup/#what-you-need)
- [Step by step: Invoke-RestMethod through a proxy](https://quanticdata.io/blog/powershell-proxy-setup/#step-by-step-invoke-restmethod-through-a-proxy)
- [Invoke-WebRequest and one session](https://quanticdata.io/blog/powershell-proxy-setup/#invoke-webrequest-and-one-session)
- [A new IP, or a state, from the same window](https://quanticdata.io/blog/powershell-proxy-setup/#a-new-ip-or-a-state-from-the-same-window)
- [A proxy for every call in the window](https://quanticdata.io/blog/powershell-proxy-setup/#a-proxy-for-every-call-in-the-window)
- [curl in PowerShell: the alias and curl.exe](https://quanticdata.io/blog/powershell-proxy-setup/#curl-in-powershell-the-alias-and-curl-exe)
- [SOCKS5 from PowerShell](https://quanticdata.io/blog/powershell-proxy-setup/#socks5-from-powershell)
- [Try it with your own line](https://quanticdata.io/blog/powershell-proxy-setup/#try-it-with-your-own-line)
- [Before you run it on a schedule](https://quanticdata.io/blog/powershell-proxy-setup/#before-you-run-it-on-a-schedule)

To use a proxy in PowerShell, put the username and password in a PSCredential and pass it with `-ProxyCredential`, next to `-Proxy` with the gateway's `http://` address, to Invoke-WebRequest or Invoke-RestMethod. For every call in a window, set both once in `$PSDefaultParameterValues`. For SOCKS5, use `curl.exe`.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=powershell-proxy-setup) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

Every command and every line of output below is real: we ran them in Windows PowerShell 5.1 on a Windows 11 PC on 20 November 2026, through QuanticData proxies. The exit IPs are masked, and USER and PASS stand for your credentials. The four console screenshots come from one session, in the order shown, redrawn with its real output.

## What you need

- **Windows PowerShell.** `$PSVersionTable.PSVersion` shows the version: our test PC printed 5.1.26100.9818.
- **A sticky proxy line.** It has the form `http://USER:PASS@HOST:PORT`, as in the table below; the username carries the country and the session. We generated ours with the generate_proxies tool of our [MCP server](https://quanticdata.io/mcp-server/). The examples use Residential Basic; the curl.exe section shows a Residential Premium and a mobile line.
- **The three parts of the line:** the gateway with its port, the username and the password. PowerShell takes them in two places, as the table shows.

| Part of the line | Where it goes in PowerShell |
| --- | --- |
| Gateway and port | `-Proxy`, with `http://` in front |
| Username | The PSCredential for `-ProxyCredential` |
| Password | The same PSCredential, as a SecureString |

```
Gateway:  http://residentialboson.quanticdata.io:10000
Username: USER-type-residential-country-us-session-ps41-lifetime-30
Password: PASS
```

## Step by step: Invoke-RestMethod through a proxy

1. **Set the gateway.** Put it in `$proxy`, as in the first line below. It is `http://` for https:// pages too: our checks loaded https://ipinfo.io this way.
2. **Build the credential.** Turn the password into a SecureString, then make a PSCredential with the whole username.
3. **Call with both parameters.** `-Proxy $proxy -ProxyCredential $cred`, on Invoke-RestMethod or Invoke-WebRequest.
4. **Read the exit.** ipinfo.io/json answers with the address the site sees and its location.

```
$proxy = "http://residentialboson.quanticdata.io:10000"
$pass = ConvertTo-SecureString "PASS" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential("USER-type-residential-country-us-session-ps41-lifetime-30", $pass)
Invoke-RestMethod -Uri "https://ipinfo.io/json" -Proxy $proxy -ProxyCredential $cred
```

![A Windows PowerShell 5.1 console setting $proxy to http://residentialboson.quanticdata.io:10000, building a PSCredential from the username USER-type-residential-country-us-session-ps41-lifetime-30 and the password, then running Invoke-RestMethod against ipinfo.io/json with -Proxy and -ProxyCredential; the real output lists the exit in Frederick, Maryland, US, on Comcast, time zone America/New_York, IP masked, with four numbered steps beside it.](https://quanticdata.io/blog/powershell-proxy-setup/powershell-invoke-restmethod-proxy-v3.webp)

*The real run of 20 November 2026: the exit in Frederick, Maryland. IP masked.*

Invoke-RestMethod turns the JSON into an object, which PowerShell prints as a list: `(Invoke-RestMethod ...).country` gives the country alone. Keep the username and password in `-ProxyCredential`: in our test, Windows PowerShell 5.1 did not use a username and password written inside the `-Proxy` URL, so the line from the generator has to be split in two.

## Invoke-WebRequest and one session

Invoke-WebRequest takes the same two parameters and returns the whole response, with the status code. We ran it with `-UseBasicParsing`, the plain parser of Windows PowerShell 5.1.

```
Invoke-WebRequest -Uri "https://ipinfo.io/json" -Proxy $proxy -ProxyCredential $cred -UseBasicParsing | Select-Object StatusCode, StatusDescription

1..3 | ForEach-Object { Invoke-RestMethod -Uri "https://ipinfo.io/json" -Proxy $proxy -ProxyCredential $cred | Select-Object ip, city, region, country }
```

![A Windows PowerShell 5.1 console in the same window: Invoke-WebRequest through the proxy returns StatusCode 200 OK, and three Invoke-RestMethod calls on the same session each return the same exit in Frederick, Maryland, US, IPs masked; two numbered steps beside it.](https://quanticdata.io/blog/powershell-proxy-setup/powershell-invoke-webrequest-session-v3.webp)

*StatusCode 200, then three calls on one session: the same exit in Frederick, Maryland, each time.*

The username carries the settings. `-country-us` picks the country, `-session-ps41` names the session and `-lifetime-30` sets the session time to 30 minutes; in our run, three calls on that session left from the same exit.

## A new IP, or a state, from the same window

Change the session ID for a new session, and add `-DisableKeepAlive` so each session ID opens its own connection to the gateway. Run in a new window, this gave three sessions and three exits:

```
$proxy = "http://residentialboson.quanticdata.io:10000"
$pass = ConvertTo-SecureString "PASS" -AsPlainText -Force
foreach ($sid in "ps51", "ps52", "ps53") {
  $c = New-Object System.Management.Automation.PSCredential("USER-type-residential-country-us-session-$sid-lifetime-30", $pass)
  Invoke-RestMethod -Uri "https://ipinfo.io/json" -Proxy $proxy -ProxyCredential $c -DisableKeepAlive | Select-Object ip, city, region, country
}

ip      city         region     country
--      ----         ------     -------
x.x.x.x Los Angeles  California US
x.x.x.x Independence Kansas     US
x.x.x.x New Castle   Delaware   US
```

The username also takes a state: with `-state-texas` the exit was in Houston.

```
$tx = New-Object System.Management.Automation.PSCredential("USER-type-residential-country-us-state-texas-session-ps45-lifetime-30", $pass)
Invoke-RestMethod -Uri "https://ipinfo.io/json" -Proxy $proxy -ProxyCredential $tx -DisableKeepAlive | Select-Object city, region, country, timezone

city    region country timezone
----    ------ ------- --------
Houston Texas  US      America/Chicago
```

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=powershell-proxy-setup) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## A proxy for every call in the window

When a script calls Invoke-RestMethod many times, setting `-Proxy` on each call is easy to forget. `$PSDefaultParameterValues` gives a cmdlet's parameter a default value for the rest of the session:

```
$PSDefaultParameterValues["Invoke-RestMethod:Proxy"] = $proxy
$PSDefaultParameterValues["Invoke-RestMethod:ProxyCredential"] = $cred
$PSDefaultParameterValues["Invoke-WebRequest:Proxy"] = $proxy
$PSDefaultParameterValues["Invoke-WebRequest:ProxyCredential"] = $cred
```

![A Windows PowerShell 5.1 console setting $PSDefaultParameterValues so Invoke-RestMethod and Invoke-WebRequest use the proxy and its credential by default, then Invoke-RestMethod, Invoke-WebRequest and the curl alias called without proxy parameters, all leaving from the same session in Frederick, Maryland, US, IPs masked; three numbered steps beside it.](https://quanticdata.io/blog/powershell-proxy-setup/powershell-proxy-whole-window-v3.webp)

*Same window, same session: calls without proxy parameters, and the curl alias, leave from Frederick, Maryland.*

- **It lasts for the window.** A new PowerShell window starts without it.
- **To stop it** in the same window, run `$PSDefaultParameterValues.Clear()`; the next call goes out on your own connection.

## curl in PowerShell: the alias and curl.exe

In Windows PowerShell, `curl` is not curl: `Get-Alias curl` shows `curl -> Invoke-WebRequest`. So curl options fail, and `curl -x $proxy https://ipinfo.io/ip` stops with "A parameter cannot be found that matches parameter name 'x'." The real curl ships with Windows 11 as `curl.exe` (curl 8.22.0 on our PC); type the `.exe` to reach it, and the options of [how to use a proxy with curl](https://quanticdata.io/blog/how-to-use-a-proxy-with-curl/) work as written.

```
curl.exe -x http://residentialpremium.quanticdata.io:8080 -U "USER-country-de-sid-ps46-ttl-60m:PASS" https://ipinfo.io/json
curl.exe -x socks5h://mobile.quanticdata.io:1080 -U "USER-country-us-type-mobile-sid-ps47-ttl-30m:PASS" https://ipinfo.io/json
```

![A Windows PowerShell 5.1 console: Get-Alias shows curl is an alias of Invoke-WebRequest, curl -x fails because the parameter x does not exist, -Proxy with a socks5:// address is refused by Windows PowerShell 5.1, curl.exe -x with the Residential Premium gateway on port 8080 exits in Schweinfurt, Bavaria, Germany, and curl.exe with socks5h://mobile.quanticdata.io:1080 exits in the city of Mobile, Alabama, on T-Mobile USA; output shortened, IPs masked, three numbered steps beside it.](https://quanticdata.io/blog/powershell-proxy-setup/powershell-curl-alias-curl-exe-socks5-v3.webp)

*The alias, then the real curl.exe: Residential Premium in Germany over HTTP, a mobile line in the United States over SOCKS5. Output shortened.*

## SOCKS5 from PowerShell

The `-Proxy` parameter of Windows PowerShell 5.1 takes an `http://` address. Given `socks5://`, it stops with "The ServicePointManager does not support proxies with the socks5 scheme." For SOCKS5, call curl.exe from PowerShell, as in the second command above: `socks5h://` lets the proxy look up the site's name, and `-U` carries the username and password. Our mobile line on port 1080 left from the city of Mobile, Alabama, on T-Mobile USA. More on the protocol on the page for [SOCKS5 proxies](https://quanticdata.io/socks5-proxies/).

## Try it with your own line

**Try it on a free proxy trial.** The [proxy free trial](https://quanticdata.io/proxy-free-trial/) gives 100 MB of Residential Basic, the plan used for the Invoke-RestMethod examples above, so you can run them with your own line. The plans are on the pages for [QuanticData residential proxies](https://quanticdata.io/residential-proxies/) and [mobile proxies](https://quanticdata.io/mobile-proxies/). For the same jobs in other tools, see [wget with a proxy](https://quanticdata.io/blog/wget-proxy-setup/) and [a proxy in Python Requests](https://quanticdata.io/blog/how-to-use-a-proxy-with-python-requests/).

## Before you run it on a schedule

A proxy changes where PowerShell's requests come from, not what you may do on a site. Keep to each site's terms and to the law where you work, and keep the password out of scripts you share: read it at run time instead of writing it in the file.

### Sources & further reading

- [Microsoft Learn: Invoke-WebRequest](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-5.1)
- [Microsoft Learn: Invoke-RestMethod](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-5.1)
- [Microsoft Learn: about_Parameters_Default_Values](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parameters_default_values?view=powershell-5.1)
- [curl manual: -x, --proxy](https://curl.se/docs/manpage.html#-x)
- [RFC 1928: SOCKS Protocol Version 5](https://www.rfc-editor.org/rfc/rfc1928)

## FAQ

Quick answers on powershell invoke-webrequest proxy.

[Something else? Ask us](mailto:hello@quanticdata.io)

### How do I use a proxy with Invoke-WebRequest?

Pass the gateway with `-Proxy "http://HOST:PORT"` and the login with `-ProxyCredential`, a PSCredential built from the username and a SecureString password. We ran it on Windows PowerShell 5.1 with `-UseBasicParsing`. Invoke-RestMethod takes the same two parameters.

### How do I pass a proxy username and password in PowerShell?

Make a PSCredential: `$pass = ConvertTo-SecureString "PASS" -AsPlainText -Force`, then `$cred = New-Object System.Management.Automation.PSCredential("USER", $pass)`, and pass it with `-ProxyCredential $cred`. In our test, Windows PowerShell 5.1 did not use a username and password written inside the `-Proxy` URL.

### How do I set a proxy for every request in a PowerShell session?

Give the parameters a default value: `$PSDefaultParameterValues["Invoke-RestMethod:Proxy"] = $proxy` and `$PSDefaultParameterValues["Invoke-RestMethod:ProxyCredential"] = $cred`, and the same for Invoke-WebRequest. It lasts until the window closes or you run `$PSDefaultParameterValues.Clear()`.

### Why does curl -x not work in PowerShell?

In Windows PowerShell, `curl` is an alias of Invoke-WebRequest, which has no `-x` parameter. Type `curl.exe` to run the real curl that ships with Windows 11, or use `-Proxy` and `-ProxyCredential` with the alias.

### Can PowerShell use a SOCKS5 proxy?

Not with `-Proxy` in Windows PowerShell 5.1: a `socks5://` address stops with "The ServicePointManager does not support proxies with the socks5 scheme." Call curl.exe instead: `curl.exe -x socks5h://HOST:1080 -U "USER:PASS" URL`.

### How do I get a different exit in PowerShell?

Use a new session ID in the username and add `-DisableKeepAlive`, so each session ID opens its own connection to the gateway. In our run, three session IDs gave three exits, all in the United States.

## A home or carrier IP for your PowerShell scripts

Residential and mobile proxies with country and state targeting for your PowerShell scripts.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=powershell-proxy-setup) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Related reading

- [curl Basic Auth: -u, Header, .netrc, Proxy](https://quanticdata.io/blog/curl-basic-auth/): Proxies · curl -u user:password sends HTTP basic authentication: curl base64-encodes the pair into an Authorization header. Below: the header we captured with -v, the same header built by hand, passwords with colons and @, the prompt, .netrc, digest, and why a proxy login goes in -U, not -u.
- [curl Download File: -O, -o, -L and Resume](https://quanticdata.io/blog/curl-download-file/): Proxies · curl -O URL saves the file under its remote name, curl -o name URL under the name you choose, and -L follows redirects such as GitHub's. Below: every option run for real, including the 0-byte file a 302 leaves behind, a resumed download that matched the original byte for byte, and 1 MB through residential and mobile proxies.
- [curl Show Response Headers and Send Headers](https://quanticdata.io/blog/curl-headers/): Proxies · curl -i prints the response headers with the body, -I only the headers (with a HEAD request), and -D - -o /dev/null the headers of a normal GET. To send headers, use -H "Name: value", once per header. Below: all of it run for real, plus a single header with -w, removing curl's defaults, headers from a file, and what a proxy sees.

---

Source: https://quanticdata.io/blog/powershell-proxy-setup/ · Site index for AI: https://quanticdata.io/llms.txt
