Recently I was working at a project at a new client and needed to add some tools to my development machine. So I turned to one of my favorite tools for getting the apps and tools I need, Chocolatey. The only problem was that I was getting an error installing Chocolatey using the command on their website.
Exception calling "DownloadString" with "1" argument(s): "The remote server returned an error: (407) Proxy Authentication Required."
At line:1 char:47
+ iex ((new-object net.webclient).DownloadString <<<< ('https://chocolatey.org/install.ps1'))
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
After some google-binging I found a useful article on Stack Overflow that got me the hints I needed. I had to modify the command to force the WebRequest to use (of all things) the Default Credentials for the proxy setting. I didn’t have to add username/password info or anything. This is what seemed odd to me, having to set the setting to the “default”.
Here is the command I finally used:
@powershell -NoProfile -ExecutionPolicy Unrestricted -Command "[Net.WebRequest]::DefaultWebProxy.Credentials = [Net.CredentialCache]::DefaultCredentials; iex ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
Hopefully this will be helpful to someone else out there running into a corporate proxy.comments powered by Disqus