Route HTTP requests through KnoxProxy using PowerShell's Invoke-WebRequest and Invoke-RestMethod cmdlets. Works on Windows, macOS, and Linux.
Use Invoke-WebRequest with the -Proxy parameter.
$proxy = "http://gw.knoxproxy.com:7000"
$cred = New-Object System.Management.Automation.PSCredential(
"USER", (ConvertTo-SecureString "PASS" -AsPlainText -Force)
)
Invoke-WebRequest -Uri "https://httpbin.org/ip" `
-Proxy $proxy -ProxyCredential $credGet parsed JSON output directly.
$result = Invoke-RestMethod -Uri "https://httpbin.org/ip" `
-Proxy $proxy -ProxyCredential $cred
Write-Output $result.originTarget a specific country by modifying the username.
$cred = New-Object System.Management.Automation.PSCredential(
"USER-country-de", (ConvertTo-SecureString "PASS" -AsPlainText -Force)
)
Invoke-RestMethod -Uri "https://httpbin.org/ip" `
-Proxy $proxy -ProxyCredential $credMaintain the same exit IP across requests.
$cred = New-Object System.Management.Automation.PSCredential(
"USER-session-abc123", (ConvertTo-SecureString "PASS" -AsPlainText -Force)
)
# Both requests use the same exit IP
$r1 = Invoke-RestMethod -Uri "https://httpbin.org/ip" -Proxy $proxy -ProxyCredential $cred
$r2 = Invoke-RestMethod -Uri "https://httpbin.org/ip" -Proxy $proxy -ProxyCredential $cred
Write-Output $r1.origin, $r2.originSet the default proxy for all .NET HttpClient requests in the session.
[System.Net.WebRequest]::DefaultWebProxy = New-Object System.Net.WebProxy("http://gw.knoxproxy.com:7000")
[System.Net.WebRequest]::DefaultWebProxy.Credentials = New-Object System.Net.NetworkCredential("USER", "PASS")
# Now all requests use the proxy
Invoke-RestMethod -Uri "https://httpbin.org/ip"Download a file while routing through KnoxProxy.
Invoke-WebRequest -Uri "https://example.com/file.zip" `
-Proxy $proxy -ProxyCredential $cred `
-OutFile "file.zip"# KnoxProxy + PowerShell
$proxy = "http://gw.knoxproxy.com:7000"
$cred = New-Object System.Management.Automation.PSCredential(
"USER", (ConvertTo-SecureString "PASS" -AsPlainText -Force)
)
$result = Invoke-RestMethod -Uri "https://httpbin.org/ip" `
-Proxy $proxy -ProxyCredential $cred
Write-Output "Exit IP: $($result.origin)"Each Invoke-WebRequest or Invoke-RestMethod call gets a fresh exit IP. For sticky sessions, set the username to USER-session-{id} in the PSCredential.
| Problem | Fix |
|---|---|
| 407 ProxyAuthenticationRequired | Create a PSCredential object and pass it with -ProxyCredential. Ensure the username and password are correct. |
| The underlying connection was closed | Force TLS 1.2: [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 |
| Invoke-WebRequest: The proxy tunnel request to gw.knoxproxy.com failed | Test connectivity: Test-NetConnection gw.knoxproxy.com -Port 7000. Check DNS and firewall rules. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
Invoke-WebRequest does not natively support SOCKS5. Use the .NET HttpClient with a SocksProxy handler, or use curl.exe (bundled with Windows 10+) with --socks5.
Invoke-RestMethod auto-parses JSON/XML responses and returns objects. Invoke-WebRequest returns the raw response with headers. Both support -Proxy and -ProxyCredential.
Add the DefaultWebProxy configuration to your PowerShell profile ($PROFILE). It will run on every session start.
Each cmdlet call gets a fresh IP by default. Do not add a session ID to the username if you want rotation.
Free trial on rotating residential -- 2 minutes setup, no credit card.