我的机器没有代理,并且已连接到Internet,但是运行此命令会出错
((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Exception calling "DownloadString" with "1" argument(s): "Unable to connect to the remote server"
仅当我设置WebClient.Proxy = $ null时它才有效,因此以下代码有效
$client= New-Object System.Net.WebClient
$client.Proxy=$null
$client.DownloadString('https://chocolatey.org/install.ps1')
我不知道WebClient的默认值是什么,它使它不起作用,还有,是否可以将Proxy全局设置为null,所以我不必为每个WebClient调用更改此值