我正在尝试在代理后面的 Windows 上安装 Chocolatey:
@powershell -ExecutionPolicy unrestricted
Run Code Online (Sandbox Code Playgroud)
在电源外壳中我正在执行
$wc=new-object net.webclient;
$wc.Proxy=new-object system.net.WebProxy('<myproxy-ip>:8012',$true);
$wc.Proxy.Credentials = new-object system.net.NetworkCredential('<myusername>','<mypass>');
iex ($wc.DownloadString('https://chocolatey.org/install.ps1'));
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."
At line:1 char:1
+ iex ($wc.DownloadString('https://chocolatey.org/install.ps1'));
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Run Code Online (Sandbox Code Playgroud)
我使用与启动 firefox/iexplorer 时必须输入的用户名/密码相同的用户名/密码(参见图片)。没有为代理配置默认用户名/密码,因为我必须始终输入它们。
更多详细信息(在私有窗口上的 firefox 中使用 Inspect Element)
响应头
Cache-Control: no-cache
Connection: close
Content-Length: 813
Content-Type: text/html; charset=utf-8
Pragma: no-cache
Proxy-Authenticate: BASIC realm="PROXY_INTERNET"
Proxy-Connection: close
Set-Cookie: …Run Code Online (Sandbox Code Playgroud)