Proxy configuration in powershell The 2019 Stack Overflow Developer Survey Results Are In ...

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

What information about me do stores get via my credit card?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Python - Fishing Simulator

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?

Did God make two great lights or did He make the great light two?

Why did all the guest students take carriages to the Yule Ball?

Keeping a retro style to sci-fi spaceships?

Four Colour Theorem

How many people can fit inside Mordenkainen's Magnificent Mansion?

Difference between "generating set" and free product?

I could not break this equation. Please help me

Segmentation fault output is suppressed when piping stdin into a function. Why?

how can a perfect fourth interval be considered either consonant or dissonant?

Sort a list of pairs representing an acyclic, partial automorphism

How to split my screen on my Macbook Air?

Simulating Exploding Dice

Can withdrawing asylum be illegal?

Hiding Certain Lines on Table

Semisimplicity of the category of coherent sheaves?

Can a 1st-level character have an ability score above 18?

Can a novice safely splice in wire to lengthen 5V charging cable?

What force causes entropy to increase?

Make it rain characters



Proxy configuration in powershell



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Change Proxy with PowerShellUbuntu System-Wide Proxy Auto-Configuration (PAC) scriptsquid proxy server configurationSwitch global proxy configuration in OS XPowershell - acquire the system proxyRetrieve internet proxy server address via PowerShellUse powershell to run cygwin configuration fileproxy server configuration using NetworkManager nmcliPowerShell tries to use a proxy even though I have none selectedPowershell Core on linux through Proxy connection issues





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







4















I'm trying to install chocolatey on an windows behind a proxy:



@powershell -ExecutionPolicy unrestricted


In power shell I'm executing



$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'));


I get the following error



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


I use the same username/password that I must enter when I'm starting firefox/iexplorer (see the image). There are no default username/passwords configured for the proxy since I must always enter them.



enter image description here





More details (using Inspect Element in firefox on an Private Window)



Response Headers



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: BCSI-CS-dfaeac52a135c7c0=2; Path=/









share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • .Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

    – Ƭᴇcʜιᴇ007
    Sep 10 '15 at 14:32











  • @Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

    – raisercostin
    Sep 10 '15 at 15:09











  • No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

    – Daniel B
    Sep 10 '15 at 16:17











  • I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

    – raisercostin
    Sep 11 '15 at 9:09











  • The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

    – Tod Thomson
    Apr 18 '16 at 0:43


















4















I'm trying to install chocolatey on an windows behind a proxy:



@powershell -ExecutionPolicy unrestricted


In power shell I'm executing



$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'));


I get the following error



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


I use the same username/password that I must enter when I'm starting firefox/iexplorer (see the image). There are no default username/passwords configured for the proxy since I must always enter them.



enter image description here





More details (using Inspect Element in firefox on an Private Window)



Response Headers



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: BCSI-CS-dfaeac52a135c7c0=2; Path=/









share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • .Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

    – Ƭᴇcʜιᴇ007
    Sep 10 '15 at 14:32











  • @Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

    – raisercostin
    Sep 10 '15 at 15:09











  • No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

    – Daniel B
    Sep 10 '15 at 16:17











  • I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

    – raisercostin
    Sep 11 '15 at 9:09











  • The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

    – Tod Thomson
    Apr 18 '16 at 0:43














4












4








4


1






I'm trying to install chocolatey on an windows behind a proxy:



@powershell -ExecutionPolicy unrestricted


In power shell I'm executing



$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'));


I get the following error



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


I use the same username/password that I must enter when I'm starting firefox/iexplorer (see the image). There are no default username/passwords configured for the proxy since I must always enter them.



enter image description here





More details (using Inspect Element in firefox on an Private Window)



Response Headers



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: BCSI-CS-dfaeac52a135c7c0=2; Path=/









share|improve this question
















I'm trying to install chocolatey on an windows behind a proxy:



@powershell -ExecutionPolicy unrestricted


In power shell I'm executing



$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'));


I get the following error



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


I use the same username/password that I must enter when I'm starting firefox/iexplorer (see the image). There are no default username/passwords configured for the proxy since I must always enter them.



enter image description here





More details (using Inspect Element in firefox on an Private Window)



Response Headers



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: BCSI-CS-dfaeac52a135c7c0=2; Path=/






proxy powershell






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 11 '15 at 7:47







raisercostin

















asked Sep 10 '15 at 14:14









raisercostinraisercostin

2031310




2031310





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • .Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

    – Ƭᴇcʜιᴇ007
    Sep 10 '15 at 14:32











  • @Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

    – raisercostin
    Sep 10 '15 at 15:09











  • No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

    – Daniel B
    Sep 10 '15 at 16:17











  • I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

    – raisercostin
    Sep 11 '15 at 9:09











  • The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

    – Tod Thomson
    Apr 18 '16 at 0:43



















  • .Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

    – Ƭᴇcʜιᴇ007
    Sep 10 '15 at 14:32











  • @Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

    – raisercostin
    Sep 10 '15 at 15:09











  • No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

    – Daniel B
    Sep 10 '15 at 16:17











  • I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

    – raisercostin
    Sep 11 '15 at 9:09











  • The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

    – Tod Thomson
    Apr 18 '16 at 0:43

















.Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

– Ƭᴇcʜιᴇ007
Sep 10 '15 at 14:32





.Net credentials are not the same as a name and password you would type into a browser-based proxy authentication screen. Perhaps better describe the proxy and how you enter your UN/Password when using FF or IE.

– Ƭᴇcʜιᴇ007
Sep 10 '15 at 14:32













@Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

– raisercostin
Sep 10 '15 at 15:09





@Ƭᴇcʜιᴇ007 I hope the image helps with identifying the type of proxy.

– raisercostin
Sep 10 '15 at 15:09













No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

– Daniel B
Sep 10 '15 at 16:17





No, that's not enough. We'd need the HTTP response headers where the proxy is asking for authentication.

– Daniel B
Sep 10 '15 at 16:17













I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

– raisercostin
Sep 11 '15 at 9:09





I added the response headers from browser. I don't know how I could "debug" or capture the response headers in powershell. Do you have any suggestion?

– raisercostin
Sep 11 '15 at 9:09













The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

– Tod Thomson
Apr 18 '16 at 0:43





The above example worked fine for me on Windows 7 behind an NTLM proxy :) thanks.

– Tod Thomson
Apr 18 '16 at 0:43










3 Answers
3






active

oldest

votes


















0














Can't test it (don't have a similar Proxy available to me), so I actually have no idea if this will work, but here's something you can try:



$wc = new-object net.webclient;
$proxyUri = new-object system.uri("http://<myproxy-ip>:8012");
$wc.Proxy = new-object system.net.WebProxy($proxyUri, $true);
$cachedCredentials = new-object system.net.CredentialCache;
$netCredential = new-object system.net.NetworkCredential("<myusername>", "<mypass>");

$cachedCredentials.Add($proxyUri, "Basic", $netCredential);

$wc.Proxy.Credentials = $cachedCredentials.GetCredential($proxyUri, "Basic");

iex ($wc.DownloadString("https://chocolatey.org/install.ps1"));


The intention is to use a CredentialCache object to force the credentials into using "Basic" authentication mode.






share|improve this answer































    0














    See https://github.com/chocolatey/chocolatey/wiki/Proxy-Settings-for-Chocolatey



    In powershell define the function



    function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword){
    #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
    $proxyUrl = $proxyHost+":"+$proxyPort;
    Write-Host "proxy url [$proxyUrl]";
    $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
    $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
    $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
    return $proxy;
    }


    call it like



    $wc=new-object net.webclient;
    $wc.UseDefaultCredentials = $true
    $wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
    $wc.DownloadString('https://chocolatey.org/install.ps1');




    What I discovered is that the actual download worked, but the execution of the installer didn't since it used a custom constructed proxy.



    So the iex ($wc.DownloadString("https://chocolatey.org/install.ps1")); fails because the bad proxy configuration inside the downloaded install.ps1






    share|improve this answer

































      0














      You can use this. Worked for me.
      https://github.com/chocolatey/choco/wiki/Proxy-Settings-for-Chocolatey



      Explicit Proxy Settings



      Chocolatey has explicit proxy support starting with 0.9.9.9.



      You can simply configure 1 or 3 settings and Chocolatey will use a proxy server. proxy is required and is the location and port of the proxy server. proxyUser and proxyPassword are optional. The values for user/password are only used for credentials when both are present.



      choco config set proxy <locationandport>
      choco config set proxyUser <username>
      choco config set proxyPassword <passwordThatGetsEncryptedInFile>


      Example



      Running the following commands in 0.9.9.9:



      choco config set proxy http://localhost:8888
      choco config set proxyUser bob
      choco config set proxyPassword 123Sup#rSecur3





      share|improve this answer
























      • This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

        – anaximander
        May 18 '17 at 12:21












      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "3"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f971103%2fproxy-configuration-in-powershell%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      Can't test it (don't have a similar Proxy available to me), so I actually have no idea if this will work, but here's something you can try:



      $wc = new-object net.webclient;
      $proxyUri = new-object system.uri("http://<myproxy-ip>:8012");
      $wc.Proxy = new-object system.net.WebProxy($proxyUri, $true);
      $cachedCredentials = new-object system.net.CredentialCache;
      $netCredential = new-object system.net.NetworkCredential("<myusername>", "<mypass>");

      $cachedCredentials.Add($proxyUri, "Basic", $netCredential);

      $wc.Proxy.Credentials = $cachedCredentials.GetCredential($proxyUri, "Basic");

      iex ($wc.DownloadString("https://chocolatey.org/install.ps1"));


      The intention is to use a CredentialCache object to force the credentials into using "Basic" authentication mode.






      share|improve this answer




























        0














        Can't test it (don't have a similar Proxy available to me), so I actually have no idea if this will work, but here's something you can try:



        $wc = new-object net.webclient;
        $proxyUri = new-object system.uri("http://<myproxy-ip>:8012");
        $wc.Proxy = new-object system.net.WebProxy($proxyUri, $true);
        $cachedCredentials = new-object system.net.CredentialCache;
        $netCredential = new-object system.net.NetworkCredential("<myusername>", "<mypass>");

        $cachedCredentials.Add($proxyUri, "Basic", $netCredential);

        $wc.Proxy.Credentials = $cachedCredentials.GetCredential($proxyUri, "Basic");

        iex ($wc.DownloadString("https://chocolatey.org/install.ps1"));


        The intention is to use a CredentialCache object to force the credentials into using "Basic" authentication mode.






        share|improve this answer


























          0












          0








          0







          Can't test it (don't have a similar Proxy available to me), so I actually have no idea if this will work, but here's something you can try:



          $wc = new-object net.webclient;
          $proxyUri = new-object system.uri("http://<myproxy-ip>:8012");
          $wc.Proxy = new-object system.net.WebProxy($proxyUri, $true);
          $cachedCredentials = new-object system.net.CredentialCache;
          $netCredential = new-object system.net.NetworkCredential("<myusername>", "<mypass>");

          $cachedCredentials.Add($proxyUri, "Basic", $netCredential);

          $wc.Proxy.Credentials = $cachedCredentials.GetCredential($proxyUri, "Basic");

          iex ($wc.DownloadString("https://chocolatey.org/install.ps1"));


          The intention is to use a CredentialCache object to force the credentials into using "Basic" authentication mode.






          share|improve this answer













          Can't test it (don't have a similar Proxy available to me), so I actually have no idea if this will work, but here's something you can try:



          $wc = new-object net.webclient;
          $proxyUri = new-object system.uri("http://<myproxy-ip>:8012");
          $wc.Proxy = new-object system.net.WebProxy($proxyUri, $true);
          $cachedCredentials = new-object system.net.CredentialCache;
          $netCredential = new-object system.net.NetworkCredential("<myusername>", "<mypass>");

          $cachedCredentials.Add($proxyUri, "Basic", $netCredential);

          $wc.Proxy.Credentials = $cachedCredentials.GetCredential($proxyUri, "Basic");

          iex ($wc.DownloadString("https://chocolatey.org/install.ps1"));


          The intention is to use a CredentialCache object to force the credentials into using "Basic" authentication mode.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Sep 10 '15 at 15:54









          Ƭᴇcʜιᴇ007Ƭᴇcʜιᴇ007

          100k14158221




          100k14158221

























              0














              See https://github.com/chocolatey/chocolatey/wiki/Proxy-Settings-for-Chocolatey



              In powershell define the function



              function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword){
              #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
              $proxyUrl = $proxyHost+":"+$proxyPort;
              Write-Host "proxy url [$proxyUrl]";
              $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
              $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
              $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
              return $proxy;
              }


              call it like



              $wc=new-object net.webclient;
              $wc.UseDefaultCredentials = $true
              $wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
              $wc.DownloadString('https://chocolatey.org/install.ps1');




              What I discovered is that the actual download worked, but the execution of the installer didn't since it used a custom constructed proxy.



              So the iex ($wc.DownloadString("https://chocolatey.org/install.ps1")); fails because the bad proxy configuration inside the downloaded install.ps1






              share|improve this answer






























                0














                See https://github.com/chocolatey/chocolatey/wiki/Proxy-Settings-for-Chocolatey



                In powershell define the function



                function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword){
                #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
                $proxyUrl = $proxyHost+":"+$proxyPort;
                Write-Host "proxy url [$proxyUrl]";
                $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
                $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
                $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
                return $proxy;
                }


                call it like



                $wc=new-object net.webclient;
                $wc.UseDefaultCredentials = $true
                $wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
                $wc.DownloadString('https://chocolatey.org/install.ps1');




                What I discovered is that the actual download worked, but the execution of the installer didn't since it used a custom constructed proxy.



                So the iex ($wc.DownloadString("https://chocolatey.org/install.ps1")); fails because the bad proxy configuration inside the downloaded install.ps1






                share|improve this answer




























                  0












                  0








                  0







                  See https://github.com/chocolatey/chocolatey/wiki/Proxy-Settings-for-Chocolatey



                  In powershell define the function



                  function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword){
                  #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
                  $proxyUrl = $proxyHost+":"+$proxyPort;
                  Write-Host "proxy url [$proxyUrl]";
                  $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
                  $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
                  $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
                  return $proxy;
                  }


                  call it like



                  $wc=new-object net.webclient;
                  $wc.UseDefaultCredentials = $true
                  $wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
                  $wc.DownloadString('https://chocolatey.org/install.ps1');




                  What I discovered is that the actual download worked, but the execution of the installer didn't since it used a custom constructed proxy.



                  So the iex ($wc.DownloadString("https://chocolatey.org/install.ps1")); fails because the bad proxy configuration inside the downloaded install.ps1






                  share|improve this answer















                  See https://github.com/chocolatey/chocolatey/wiki/Proxy-Settings-for-Chocolatey



                  In powershell define the function



                  function Create-Proxy($proxyHost,$proxyPort,$proxyUsername,$proxyPassword){
                  #$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
                  $proxyUrl = $proxyHost+":"+$proxyPort;
                  Write-Host "proxy url [$proxyUrl]";
                  $proxy = New-Object System.Net.WebProxy($proxyUrl, $true);
                  $passwd = ConvertTo-SecureString $proxyPassword -AsPlainText -Force; ## Website credentials
                  $proxy.Credentials = New-Object System.Management.Automation.PSCredential ($proxyUsername, $passwd);
                  return $proxy;
                  }


                  call it like



                  $wc=new-object net.webclient;
                  $wc.UseDefaultCredentials = $true
                  $wc.Proxy = Create-Proxy "<proxy-host>" "<proxy-port>" "<proxy-username>" "<proxy-clear-pass>"
                  $wc.DownloadString('https://chocolatey.org/install.ps1');




                  What I discovered is that the actual download worked, but the execution of the installer didn't since it used a custom constructed proxy.



                  So the iex ($wc.DownloadString("https://chocolatey.org/install.ps1")); fails because the bad proxy configuration inside the downloaded install.ps1







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Sep 14 '15 at 14:36

























                  answered Sep 14 '15 at 11:22









                  raisercostinraisercostin

                  2031310




                  2031310























                      0














                      You can use this. Worked for me.
                      https://github.com/chocolatey/choco/wiki/Proxy-Settings-for-Chocolatey



                      Explicit Proxy Settings



                      Chocolatey has explicit proxy support starting with 0.9.9.9.



                      You can simply configure 1 or 3 settings and Chocolatey will use a proxy server. proxy is required and is the location and port of the proxy server. proxyUser and proxyPassword are optional. The values for user/password are only used for credentials when both are present.



                      choco config set proxy <locationandport>
                      choco config set proxyUser <username>
                      choco config set proxyPassword <passwordThatGetsEncryptedInFile>


                      Example



                      Running the following commands in 0.9.9.9:



                      choco config set proxy http://localhost:8888
                      choco config set proxyUser bob
                      choco config set proxyPassword 123Sup#rSecur3





                      share|improve this answer
























                      • This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                        – anaximander
                        May 18 '17 at 12:21
















                      0














                      You can use this. Worked for me.
                      https://github.com/chocolatey/choco/wiki/Proxy-Settings-for-Chocolatey



                      Explicit Proxy Settings



                      Chocolatey has explicit proxy support starting with 0.9.9.9.



                      You can simply configure 1 or 3 settings and Chocolatey will use a proxy server. proxy is required and is the location and port of the proxy server. proxyUser and proxyPassword are optional. The values for user/password are only used for credentials when both are present.



                      choco config set proxy <locationandport>
                      choco config set proxyUser <username>
                      choco config set proxyPassword <passwordThatGetsEncryptedInFile>


                      Example



                      Running the following commands in 0.9.9.9:



                      choco config set proxy http://localhost:8888
                      choco config set proxyUser bob
                      choco config set proxyPassword 123Sup#rSecur3





                      share|improve this answer
























                      • This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                        – anaximander
                        May 18 '17 at 12:21














                      0












                      0








                      0







                      You can use this. Worked for me.
                      https://github.com/chocolatey/choco/wiki/Proxy-Settings-for-Chocolatey



                      Explicit Proxy Settings



                      Chocolatey has explicit proxy support starting with 0.9.9.9.



                      You can simply configure 1 or 3 settings and Chocolatey will use a proxy server. proxy is required and is the location and port of the proxy server. proxyUser and proxyPassword are optional. The values for user/password are only used for credentials when both are present.



                      choco config set proxy <locationandport>
                      choco config set proxyUser <username>
                      choco config set proxyPassword <passwordThatGetsEncryptedInFile>


                      Example



                      Running the following commands in 0.9.9.9:



                      choco config set proxy http://localhost:8888
                      choco config set proxyUser bob
                      choco config set proxyPassword 123Sup#rSecur3





                      share|improve this answer













                      You can use this. Worked for me.
                      https://github.com/chocolatey/choco/wiki/Proxy-Settings-for-Chocolatey



                      Explicit Proxy Settings



                      Chocolatey has explicit proxy support starting with 0.9.9.9.



                      You can simply configure 1 or 3 settings and Chocolatey will use a proxy server. proxy is required and is the location and port of the proxy server. proxyUser and proxyPassword are optional. The values for user/password are only used for credentials when both are present.



                      choco config set proxy <locationandport>
                      choco config set proxyUser <username>
                      choco config set proxyPassword <passwordThatGetsEncryptedInFile>


                      Example



                      Running the following commands in 0.9.9.9:



                      choco config set proxy http://localhost:8888
                      choco config set proxyUser bob
                      choco config set proxyPassword 123Sup#rSecur3






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Oct 29 '16 at 17:05









                      fraballifraballi

                      1012




                      1012













                      • This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                        – anaximander
                        May 18 '17 at 12:21



















                      • This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                        – anaximander
                        May 18 '17 at 12:21

















                      This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                      – anaximander
                      May 18 '17 at 12:21





                      This answer explains how to configure Chocolatey to use a proxy. The question asks how to install Chocolatey from behind a proxy. This answer will be useful after that, but it's not what the question was asking.

                      – anaximander
                      May 18 '17 at 12:21


















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Super User!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f971103%2fproxy-configuration-in-powershell%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

                      VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

                      Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...