title: How to upload using FTP in Powershell, behind a proxy?
body: <p>I am attempting to use FTP in Powershell to upload a file. I am using <code>FtpWebRequest</code> later followed by <code>GetRequestStream</code>, but this method is returning an error:</p>
  
  <blockquote>
    <p>"The requested FTP command is not supported when using HTTP proxy."</p>
  </blockquote>
  
  <p>I am indeed behind a proxy and required to be.</p>
  
  <p>How can I upload via Powershell when behind a proxy?</p>
  
  <p>This would be solely run from a <code>.ps1</code> Powershell script.</p>
  
  <p>I have also tried:</p>
  
  <pre><code>$webclient = New-Object System.Net.WebClient
  $uri = New-Object System.Uri($server)
  
  $webclient.UploadFile($uri, "C:\Test\1234567.txt")
  </code></pre>
  
  <p>Where <code>$server</code> and that file are valid. But that code returns this error:</p>
  
  <pre><code>"An exception occurred during a WebClient request."
  At C:\Test\script.ps1:101 char:26
  +     $webclient.UploadFile &lt;&lt;&lt;&lt; ($uri, "C:\Test\1234567.txt")
      + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
      + FullyQualifiedErrorId : DotNetMethodException
  </code></pre>
  
  <p>I also tried double backslashes in the file paths, didn't help.</p>
  
  <p>The proxy I am under only touches HTTP, and not FTP.</p>