
Teach you how to use PowerShell to hang a proxy to access the Internet
Programming brothers know that using PowerShell to do network requests is commonplace. But when it comes to the website to restrict IP access, the whole person is blind, not? Today we will nag how to Invoke-WebRequest this command to wear a "cloak and dagger", with a proxy IP to do the job.
What the hell is a proxy IP?
Simply put, it is to find a middleman to help you pass the word. For example, if you want to visit a certain website, first let the proxy server to contact, the website to see the IP is the proxy, with you half a penny has nothing to do. This can protect privacy, but also break through the single IP access restrictions.
For example, suppose you want to test the concurrency of a certain interface, and if you use your own IP to continuously swipe, you will be hacked in minutes. If you have dozens of proxy IPs at hand to use in turn, this will be a success.
Three Steps to Setting Up Agents in PowerShell
Here's the kicker! Hooking up a proxy with Invoke-WebRequest is actually extraordinarily simple, remember this catch-all formula:
$proxy = "http://账号:密码@ip address:port"
Invoke-WebRequest -Uri "destination URL" -Proxy $proxy -ProxyUseDefaultCredentials
Name a few easy places to plant your head:
1. Proxy address format must be with http://Many people write IP:port directly, and they can't connect to it.
2. Need account password agent, remember to use a colon to separate the account password, such as user123:pass456
3. When using ipipgo's dynamic proxy, it is recommended to change the IP address for each request to avoid being detected by the target website.
Practical case demonstration
Assuming that we are now going to use ipipgo's proxy to collect data, how do we do this exactly? Watch this:
Proxy information from ipipgo
$ipipgo_proxy = "http://vipuser:28dxz9@gateway.ipipgo.com:9020"
Request with timeout setting
$response = Invoke-WebRequest -Uri "https://target-site.com/data" `
-Proxy $ipipgo_proxy `
-TimeoutSec 30 `
-UserAgent "Mozilla/5.0"
Processing the returned results
$content = $response.Content
Note the use of backquotes ` to write commands in newlines so that the code looks fresh. If you run into certificate problems, you can add a-SkipCertificateCheckparameter, but it has to be supported by PS 7.0 or higher.
Frequently Asked Questions QA
Q:Why can't I connect even though I have set the right proxy?
A: Eighty percent of the IP is blocked, hurry to ipipgo background for a new IP. their IP pool automatically updated every 5 minutes, it is recommended to use short-term proxy package.
Q: What if I need to use more than one agent at the same time?
A: Store the proxy addresses in an array and randomly select one at a time:
$ipipgo_pool = @("ip1:port", "ip2:port", "ip3:port")
$random_proxy = Get-Random -InputObject $ipipgo_pool
Q: What if the return speed is particularly slow?
A: It is possible that the line is congested, switch the server room node in the ipipgo console. PrioritizeBGP hybrid lineThe optimal path is selected automatically.
Why do you recommend ipipgo?
Self-used experience:
- Exclusive IP pool, no public proxies.
- Support HTTP/HTTPS/Socks5 three protocols
- Maximum survival time per IP down to the second.
- 24-hour technical customer service, the last time at two o'clock in the middle of the night to mention the work order actually seconds back!
One last tawdry maneuver: write the proxy settings as a function and put it into the$PROFILEI can use it every time I open PowerShell in the future. Need code brother to ipipgo official website to find customer service to sample scripts, report my name to play ... cough, in fact, report or not report are the same, their price is already real.

