1

I am developing a PowerShell script that uses HTTP to access REST services. For debugging purposes I want to redirect all HTTP traffic created by that script through a local proxy (Fiddler).

What I don't want to is to set Fiddler as system wide proxy in IE/ Windows internet settings as this would redirect the traffic of my whole system through Fiddler (especially because Fiddler decrypts SSL/TLS traffic).

How do I set a proxy that affects only one WebClient instance or only the PowerShell?

1 Answer 1

3

Use the WebProxy class and instantiate it with the address to Fiddler (listens on port 8888 by default):

$FiddlerWP = New-Object System.Net.WebProxy "http://127.0.0.1:8888"

$WebClient = New-Object System.Net.WebClient
$WebClient.Proxy = $FiddlerWP

# This request will now get proxied through Fiddler
$WebClient.DownloadString("https://test.site.example")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.