Skip to content
Get Started
G2G2
4.7/5
Excellent
Trustpilot

How to use a proxy in PowerShell

Pass the proxy and a credential to the web cmdlets: Invoke-RestMethod https://api.ipify.org -Proxy http://HOST:PORT -ProxyCredential $cred, where $cred is a PSCredential with your username and password. Invoke-WebRequest takes the same parameters, in both Windows PowerShell 5.1 and PowerShell 7.

  • Session Control
  • High Speed
  • Privacy First

What you need

PowerShell is how many Windows admins and automation scripts call web APIs. The two editions find proxies differently: Windows PowerShell 5.1 follows the Windows proxy settings, while PowerShell 7 reads HTTP_PROXY, HTTPS_PROXY and NO_PROXY first. Passing -Proxy explicitly behaves the same in both.

Your credential line

From the dashboard's proxy manager: host (or IP), port, username and password. Convert lists with the proxy list formatter.

PowerShell ready

  • Windows PowerShell 5.1 (built into Windows) or PowerShell 7 on Windows, macOS or Linux; check $PSVersionTable.PSVersion.
  • PowerShell 7.2 or later for SOCKS5.

Which proxy fits PowerShell?

Both products use the same setup in PowerShell. What changes is how long an IP stays with you.

An ISP line is one dedicated US IP for the whole month, so a -WebSession object plus the same ISP proxy on every call keeps an account's cookies and IP together. SOCKS5 on ISP lines works in PowerShell 7.2 and later.

starting from$0.75/IP

Dedicated static IPs registered to US and Canadian ISPs. The address stays the same for as long as you hold it, with unlimited bandwidth and HTTP(S) or SOCKS5 access.

Each new connection through a rotating line can get a new residential IP, but calls in the same web session can reuse a connection. Use a sticky line when a script must stay on one IP for its whole run, and separate calls without -WebSession when you want rotation.

starting from$0.63/GB

Residential IPs in 190+ countries with country, state and city targeting. Rotate on every request or hold a sticky session for up to 90 minutes; GB never expire.

credentials

Your CleanProxies credentials

Every product connects over HTTP(S); static ISP and ISP subnet proxies also run SOCKS5 and IP whitelisting. This is what the dashboard gives you to paste into PowerShell.

Static ISP and ISP subnetHTTP(S)SOCKS5IP whitelist
IP:PORT:USER:PASS

One line per dedicated IP. With IP whitelisting on, the line is just IP:PORT and no password is sent.

Rotating residential and mobileHTTP(S)User:pass
HOST:PORT:USER:PASS

Generated in the proxy manager. The username carries the location and session you pick, so generate a new list to change them.

As a URL, for code and most toolshttp://USERNAME:PASSWORD@HOST:PORTsocks5://USERNAME:PASSWORD@HOST:PORT

Use http:// even for HTTPS websites; the TLS session still runs end to end. The socks5:// form is for static ISP and ISP subnet proxies.

How to set up CleanProxies in PowerShell

Four steps, then check the exit IP with the free proxy checker.

  1. 1

    Check your version

    Run $PSVersionTable.PSVersion. 5.1 is Windows PowerShell; 7.x is PowerShell (pwsh).

  2. 2

    Create a credential

    Build a PSCredential from your username and password, or run Get-Credential to type them in a prompt.

  3. 3

    Call the cmdlet with -Proxy

    Add -Proxy http://HOST:PORT -ProxyCredential $cred to Invoke-WebRequest or Invoke-RestMethod.

  4. 4

    Compare the IPs

    Call https://api.ipify.org with and without the proxy; the two addresses should differ.

copy & paste

PowerShell proxy examples

Replace the highlighted placeholders with the values from your dashboard. Pick an example to see its code.

PowerShell + CleanProxies

Invoke-RestMethod and Invoke-WebRequest with a proxy

HTTP(S) proxy with a PSCredentialPowerShell
$secure = ConvertTo-SecureString "PASSWORD" -AsPlainText -Force
$cred   = [pscredential]::new("USERNAME", $secure)

$params = @{
  Uri             = "https://api.ipify.org?format=json"
  Proxy           = "http://HOST:PORT"
  ProxyCredential = $cred
  TimeoutSec      = 30
}
(Invoke-RestMethod @params).ip
  • Use http://HOST:PORT for HTTPS sites too: the request is tunnelled with CONNECT and TLS runs end to end. SOCKS5 is available on static ISP and ISP subnet proxies (switched on per list in the dashboard, same credentials) and relies on the .NET SOCKS client in PowerShell 7. -ProxyUseDefaultCredentials sends your Windows sign-in to a corporate proxy; CleanProxies needs -ProxyCredential instead.
fix it fast

Troubleshooting PowerShell proxy errors

Verify your exit IP

The first line prints the proxy's exit IP and the second your own. In Windows PowerShell 5.1, drop -NoProxy and run the second line with no default proxy set.

Open What is my IP? through the proxy to see the address and headers a website receives, or paste up to ten lines into the free proxy checker to test connectivity, latency and exit IP.

Still stuck? Our 24/7 support team answers fast: contact us with the error and the line you used (leave the password out).

PowerShell error fixes
  • 407 Proxy Authentication RequiredWhy: -ProxyCredential is missing, or the username or password is wrong.Rebuild $cred from the dashboard line and pass it with -ProxyCredential on every call.
  • A parameter cannot be found that matches parameter name 'NoProxy'Why: You're in Windows PowerShell 5.1, which has no -NoProxy.Drop the switch, or run the script in PowerShell 7 (pwsh).
  • HTTP_PROXY is ignoredWhy: Windows PowerShell 5.1 doesn't read it, or PowerShell 7 was already running when you set it.Use -Proxy explicitly, or set the variables first and start a new pwsh.
  • Could not create SSL/TLS secure channel (5.1)Why: Older .NET Framework defaults in Windows PowerShell can offer outdated TLS versions.Run [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 first, or use PowerShell 7.

PowerShell proxy guides

Setup guides and best practices from the CleanProxies blog.

Get the latest insightsAll Blogs

More integrations

Setup guides for tools people run next to PowerShell.

All integrations

PowerShell proxy FAQs

Straight answers about running CleanProxies in PowerShell.

Add -Proxy with the proxy address and -ProxyCredential with a PSCredential holding your CleanProxies username and password. Invoke-RestMethod accepts the same two parameters.

Got more questions?All FAQs