Blogs‎ > ‎My Point of View ...‎ > ‎

POWERSHELL: Accessing the internet thru a Proxy

Today I needed to make this script work behind a proxy, something that I have found in the past but was not able to find a good set of instructions.
I got it working and I wanted to share it with you, in case someone else is looking for it.

all you need to do is add the following 4 lines anytime before downloading the data (I prefer to do it right after instancing the WebClient object):


$proxyObject = new-object System.Net.WebProxy("MyProxyServer", 8080)
$proxyObject.BypassProxyOnLocal = $true
$proxyObject.Credentials = [System.Net.CredentialCache]::DefaultCredentials
[System.Net.GlobalProxySelection]::Select = $proxyObject


I hope it helps.
Best regards, Marianok.

 

 


This pages are generated automatically after I post a new blog entry on My Point of View ...

but the comments are NOT being replicated.

If you want to make a comment, or take a look at the existing comments, please visit the original entry at http://mscosentino-en.blogspot.com/2011/01/powershell-accessing-internet-thru.html.

This Section is a replica of the POWERSHELL: Accessing the internet thru a Proxy

Published on Jan 21 2011 at 04:43:00

Cached copy generated on Oct 05 2012 at 06:35:18

Tags: Powershell

Comments