blog.icewolf.ch

Let's talk about IT!
posts - 1317, comments - 295, trackbacks - 0

My Links

Archives

Post Categories

icewolf

Download File from Internet with powershell and proxyauthentication

Hallo zusammen,

Heute musste ich ein Powershell Script erstellen, welches ein File aus dem Internet herunterlädt. Und dies auch noch über einen Authenticated Proxy. Am besten so, dass weder Benutzername noch Passwort im Script hinterlegt werden muss.

#/*NoProxy*/
$source = "http://www.funkykitchenclub.ch/robots.txt"
$dest = "c:\temp\file.txt"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($source,$dest)

#/*Proxy with Authentication*/
$source = "http://www.funkykitchenclub.ch/robots.txt"
$dest = "c:\temp\file.txt"
$WebClient = New-Object System.Net.WebClient
$WebProxy = New-Object System.Net.WebProxy("http://ICESRV03.corp.icewolf.ch:8080",$true)
$WebProxy.UseDefaultCredentials = $true
$WebClient.Proxy = $WebProxy
$WebClient.DownloadFile($source,$dest)

Grüsse
Andres Bohren

Print | posted on Monday, May 27, 2013 5:54 PM | Filed Under [ Powershell ]

Powered by:
Powered By Subtext Powered By ASP.NET