Getting through a proxy server with PowerShell

在使用powershell中经常需要使用到一些网上的资源,那么如何通过代理来访问网上的各种资源呢?
下面就是一种实现方式,具体的代码及说明如下:
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Net")
# 创建代理$proxy = new-object System.Net.WebProxy  "isa.pumch.local:8080"

# 设置访问代理的凭据
$cred = get-credential
$proxy.credentials = $cred.GetNetworkCredential()
#下载一个页面
$WebClient = new-object System.Net.WebClient
$WebClient.proxy = $proxy
$url = " http://www.streamline-it-solutions.co.uk/blog/post/Getting-through-a-proxy-server-with-PowerShell.aspx"
$content = $WebClient.DownloadString($url)

你可能感兴趣的:(server,proxy,powershell,休闲,getting)