title: Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send via proxy
body: <p>Error: </p>
  
  <pre><code>Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send
  
  via : proxy 
  </code></pre>
  
  <p>powershell version 4.0, the same request works with later version of powershell</p>
  
  <p>Tried to invoke web request</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$headers = @{ "Authorization" = "Bearer 7jNQ0nL"}
  Invoke-WebRequest  -Uri https://api.line.me/v2/bot/user/all/richmenu  -Method Get  -Proxy proxy.xx.xxxnet.com:8080 -ProxyUseDefaultCredentials  -Headers $headers
  </code></pre>
  
  <p>but this is what happens:</p>
  
  <pre><code>Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send.
  At line:1 char:1
  + Invoke-WebRequest  -Uri https://api.line.me/v2/bot/user/all/richmenu  -Method Ge ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
      + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
  </code></pre>