【发布时间】:2012-12-19 14:47:12
【问题描述】:
我在办公室工作,必须使用 http 代理访问互联网。
是否有任何 $PSvariable 或环境变量可以告诉 powershell 在请求外部资源时使用 http 代理? (如 linux 中的 http_proxy env var:
http_proxy=http://username:password@host:port/)
export http_proxy
我知道我可以为 webclient 做到这一点
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
$web = New-Object System.Net.WebClient
$web.proxy = $proxy
,为 pssession 做这件事
$PSSessionOption = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Negotiate -ProxyCredential Domain\User
但有时我找不到任何解决方案,例如如何通过代理使用update-help |save-help?
【问题讨论】:
-
我不需要做任何特别的事情来通过我系统上的代理访问网络。 IE 使用的设置由 PowerShell 和我系统上的几乎所有其他东西自动拾取。我不知道代理如何(甚至是否)进行身份验证 - 这可能是不同的。
-
哦哦,也许你碰到了什么......因为我不使用即代理设置可能是错误的。明天将测试并让你知道。谢谢
-
@alroc 感谢在 IE 中重新定义代理设置后它工作正常。做出回答,我会标记它
标签: .net networking powershell configuration proxy