Getting through a proxy server with PowerShell
2010-03-17 20:43
483 查看
在使用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)
下面就是一种实现方式,具体的代码及说明如下:
[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)
相关文章推荐
- Getting through a proxy server with PowerShell
- 数据库、用户-第二章Getting Start with the Oracle Server(oracle入门)-by小雨
- 02 Getting Started with the Oracle Server
- SIP Call with Proxy Server
- use jscript with List Proxy Server Information
- c5 URLs and URIs - Communicating with Server-Side Programs Through GET
- 多进程监控自动关机工具升级远程关闭多台server——C# works with PowerShell
- Layered connections through a proxy server
- 第05讲:Chapter 02--Getting Started with the Oracle Server
- How to find out why your account keeps getting locked with Windows Server, TMG and Webspy
- use jscript with List Proxy Server Information
- SMO编程初步(Getting started with SQL Server Management Objects (SMO))
- Fundamental I 02 Getting started with Oracle Server
- Getting Started with SQL Server 2008 R2 Failover Clustering
- How To Use Proxy Server To Access Internet at Shell Prompt With http_proxy Variable. [reprint]
- [转]Setting a SharePoint 2010 Config DB failover server with PowerShell
- Getting through OpenStack Quantum with Open vSwitch
- A Proxy Architecture with Aggregated Data Compression Method for HTTP Server
- [SQL in Azure] Getting Started with SQL Server in Azure Virtual Machines
- Getting Started with Microsoft Windows Workflow Foundation: A Developer Walkthrough