Get Webclient With Proxy Authentication

If your company is using an Internet proxy, and you'd like to access Internet with a webclient object, make sure it uses the proxy and supplies your default credentials to it. You could write a little helper function to get such a pre-configured webclient:

function Get-Webclient { 
    $wc = New-Object Net.WebClient
    $wc.UseDefaultCredentials = $true
    $wc.Proxy.Credentials = $wc.Credentials

Next, you could retrieve an RSS feed from the Internet. For example:
$webclient = Get-WebClient
[xml]$powershelltips = $webClient.DownloadString('')
$ | Select-Object title, link

Old Cmd S In Powershell

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License