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 = 'http://www.powershell.com'
$web.DownloadString($url)
ReTweet this Tip!
Posted
Apr 13 2012, 06:00 AM
by
ps1