Documentation Python quickstart Blog Free tools Enterprise solutions hello@quanticdata.ioLog in

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

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.
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.

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.

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. 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 lineWhere it goes in PowerShell
Gateway and port-Proxy, with http:// in front
UsernameThe PSCredential for -ProxyCredential
PasswordThe 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.
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.
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

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.
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 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.
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.

Try it with your own line

Try it on a free proxy trial. The 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 and mobile proxies. For the same jobs in other tools, see wget with a proxy and a proxy in 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

FAQ

Quick answers on powershell invoke-webrequest proxy.

Something else? Ask us

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.

Related reading