Zum Inhalt springen
Guides 2 Min. Lesezeit 730 Aufrufe

Verwenden von Proxies in PowerShell

Arbeiten mit Proxies in PowerShell: Invoke-WebRequest, System.Net.WebProxy, System-Proxy-Konfiguration und Automatisierung mittels Skript

Verwenden von Proxies in PowerShell

Proxies in PowerShell verwenden

Proxies in PowerShell

PowerShell ist ein leistungsstarkes Automatisierungstool in Windows. Die Arbeit mit Proxies ist entscheidend für Skripte, die in Unternehmensnetzwerken ausgeführt werden oder Anonymität erfordern.

Invoke-WebRequest mit Proxies

Grundlegende Anfrage über Proxy

$proxy = "http://proxy_ip:8080"
$response = Invoke-WebRequest -Uri "https://httpbin.org/ip" -Proxy $proxy
$response.Content

Mit Authentifizierung

$proxy = "http://proxy_ip:8080"
$proxyCred = New-Object System.Management.Automation.PSCredential(
    "username",
    (ConvertTo-SecureString "password" -AsPlainText -Force)
)

$response = Invoke-WebRequest -Uri "https://httpbin.org/ip" `
    -Proxy $proxy `
    -ProxyCredential $proxyCred

$response.Content

Invoke-RestMethod (für JSON API)

$proxy = "http://proxy_ip:8080"
$result = Invoke-RestMethod -Uri "https://httpbin.org/ip" -Proxy $proxy
$result.origin  # your IP via proxy

System.Net.WebProxy

Programmatische Konfiguration

$webProxy = New-Object System.Net.WebProxy("http://proxy_ip:8080", $true)
$webProxy.Credentials = New-Object System.Net.NetworkCredential("user", "pass")

# Apply to WebClient
$client = New-Object System.Net.WebClient
$client.Proxy = $webProxy
$result = $client.DownloadString("https://httpbin.org/ip")
Write-Host $result

Proxy-Umgehung für bestimmte Adressen

$webProxy = New-Object System.Net.WebProxy("http://proxy_ip:8080", $true)
$webProxy.BypassList = @("localhost", "*.local", "192.168.*")
$webProxy.BypassProxyOnLocal = $true

HttpClient (.NET)

Für fortgeschrittene Szenarien verwenden Sie den .NET HttpClient:

$proxy = New-Object System.Net.WebProxy("http://proxy_ip:8080")
$proxy.Credentials = New-Object System.Net.NetworkCredential("user", "pass")

$handler = New-Object System.Net.Http.HttpClientHandler
$handler.Proxy = $proxy
$handler.UseProxy = $true

$client = New-Object System.Net.Http.HttpClient($handler)
$response = $client.GetStringAsync("https://httpbin.org/ip").Result
Write-Host $response

System-Proxy

Aktuelle Einstellungen lesen

# From Windows Registry
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
$proxyEnabled = (Get-ItemProperty -Path $regPath).ProxyEnable
$proxyServer = (Get-ItemProperty -Path $regPath).ProxyServer
Write-Host "Proxy enabled: $proxyEnabled"
Write-Host "Proxy server: $proxyServer"

System-Proxy einstellen

$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"

# Enable proxy
Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 1
Set-ItemProperty -Path $regPath -Name ProxyServer -Value "proxy_ip:8080"

# Exceptions
Set-ItemProperty -Path $regPath -Name ProxyOverride -Value "localhost;*.local"

Write-Host "Proxy configured"

System-Proxy deaktivieren

Set-ItemProperty -Path $regPath -Name ProxyEnable -Value 0
Write-Host "Proxy disabled"

Umgebungsvariablen

Einstellen

$env:HTTP_PROXY = "http://proxy_ip:8080"
$env:HTTPS_PROXY = "http://proxy_ip:8080"
$env:NO_PROXY = "localhost,*.local"

Permanente Einstellung

[Environment]::SetEnvironmentVariable("HTTP_PROXY", "http://proxy_ip:8080", "User")
[Environment]::SetEnvironmentVariable("HTTPS_PROXY", "http://proxy_ip:8080", "User")

Überprüfung

Write-Host "HTTP_PROXY: $env:HTTP_PROXY"
Write-Host "HTTPS_PROXY: $env:HTTPS_PROXY"

Proxy-Rotation in Skripten

$proxies = @(
    "http://user:pass@proxy1:8080",
    "http://user:pass@proxy2:8080",
    "http://user:pass@proxy3:8080"
)

$urls = @(
    "https://httpbin.org/ip",
    "https://httpbin.org/headers",
    "https://httpbin.org/user-agent"
)

foreach ($url in $urls) {
    $proxy = $proxies | Get-Random
    try {
        $response = Invoke-RestMethod -Uri $url -Proxy $proxy -TimeoutSec 10
        Write-Host "OK: $url via $proxy"
        Write-Host $response
    } catch {
        Write-Host "FAIL: $url via $proxy - $($_.Exception.Message)"
    }
}

Proxy-Test

function Test-Proxy {
    param(
        [string]$ProxyServer,
        [string]$ProxyPort,
        [string]$Username,
        [string]$Password
    )

    $proxy = "http://${ProxyServer}:${ProxyPort}"
    $cred = $null

    if ($Username) {
        $cred = New-Object System.Management.Automation.PSCredential(
            $Username,
            (ConvertTo-SecureString $Password -AsPlainText -Force)
        )
    }

    try {
        $params = @{
            Uri = "https://httpbin.org/ip"
            Proxy = $proxy
            TimeoutSec = 10
        }
        if ($cred) { $params.ProxyCredential = $cred }

        $response = Invoke-RestMethod @params
        Write-Host "OK - IP: $($response.origin)" -ForegroundColor Green
        return $true
    } catch {
        Write-Host "FAIL - $($_.Exception.Message)" -ForegroundColor Red
        return $false
    }
}

# Usage
Test-Proxy -ProxyServer "proxy_ip" -ProxyPort "8080" -Username "user" -Password "pass"

Massen-Proxy-Test

$proxyList = Get-Content "proxies.txt"  # format: ip:port:user:pass

$results = foreach ($line in $proxyList) {
    $parts = $line.Split(":")
    $ip = $parts[0]; $port = $parts[1]
    $user = $parts[2]; $pass = $parts[3]

    $proxy = "http://${ip}:${port}"
    try {
        $cred = New-Object PSCredential($user, (ConvertTo-SecureString $pass -AsPlainText -Force))
        $resp = Invoke-RestMethod "https://httpbin.org/ip" -Proxy $proxy -ProxyCredential $cred -TimeoutSec 5
        [PSCustomObject]@{Proxy=$line; Status="OK"; IP=$resp.origin}
    } catch {
        [PSCustomObject]@{Proxy=$line; Status="FAIL"; IP="N/A"}
    }
}

$results | Format-Table -AutoSize
$results | Export-Csv "proxy_check_results.csv" -NoTypeInformation

Fazit

PowerShell bietet flexible Tools für die Arbeit mit Proxies: von einfachen Cmdlets (Invoke-WebRequest) bis zur vollständigen .NET API. Die Möglichkeit, System-Proxies über die Registrierung und Umgebungsvariablen zu verwalten, macht PowerShell ideal für die Automatisierung der Proxy-Konfiguration auf Windows-Maschinen.

Aktualisiert: 06.03.2026
Zurück zur Kategorie

Lesen Sie auch

Guides 2 Min.

Proxy für Nike SNKRS: Limitierte Drops ergattern & mehrere Teilnahmen sichern

Nutze Residential- oder Mobile-Proxies für Nike SNKRS, um mit mehreren Accounts an Draws teilzunehmen, IP-Limits zu umgehen und limitierte Drops ohne Bans zu coppen. Welcher Typ zu wählen ist und wie man das Setup einrichtet.

Guides 2 Min.

So richten Sie einen Proxy auf dem iPhone ein (WLAN & SOCKS5)

Richten Sie einen Proxy auf dem iPhone über die nativen Wi-Fi-Einstellungen (HTTP/HTTPS) oder eine Proxy-App wie Shadowrocket für SOCKS5 und Mobilfunkabdeckung ein. Schritt-für-Schritt-iOS-Setup und die zu beachtenden Einschränkungen.

Guides 3 Min.

Proxy für Tinder: Mehrere Accounts & Sperren vermeiden

Nutze Mobile- oder Residential-Proxies für Tinder, um mehrere Profile zu betreiben und IP-Shadowbans zu vermeiden. Warum Mobile gewinnt, wie man es einrichtet und warum ein Proxy allein nicht deinen Standort ändert.

Guides 2 Min.

Proxy für StockX: Preise überwachen & Accounts verwalten

Nutzen Sie Residential-, ISP- oder Mobile-Proxys für StockX, um Preise zu überwachen, mehrere Accounts zu verwalten und Drops ohne Bans zu coppen. Hier erfahren Sie, welchen Typ Sie wählen sollten und wie Sie GProxy einrichten.

Guides 3 Min.

Proxy für OpenAI API: Zugriff, Rate Limits & Setup

Leite die OpenAI API über einen Residential- oder ISP-Proxy (GProxy +) weiter, um auf unterstützte Regionen zuzugreifen, 429-Rate-Limits zu umgehen und Accounts zu isolieren. Welcher Proxy zu verwenden ist, plus Python-Setup-Beispiele.

Guides 1 Min.

Einrichten eines Proxys in Cypress für E2E-Tests

Einrichten eines Proxys in Cypress: HTTP_PROXY-Variablen, cy-proxy-middleware und das Testen standortabhängiger Inhalte.

Testen Sie unsere Proxys

20.000+ Proxys in über 100 Ländern weltweit

support_agent
GProxy Support
Usually replies within minutes
Hi there!
Send us a message and we'll reply as soon as possible.