Use Internet Connection with Default Proxy

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

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!

Posted Apr 13 2012, 06:00 AM by ps1
Copyright 2012 All rights reserved.