Use Internet Connection with Default Proxy

by Apr 13, 2012

If you want PowerShell to use the same proxy settings that are set in your Internet Explorer browser, then here's the code you need:

$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$web = New-Object System.Net.WebClient
$web.proxy = $proxy
$web.UseDefaultCredentials = $true

Once set up, you can then use the $web object to download web site content or even files:

$url = ''

Twitter This Tip! ReTweet this Tip!