How to upload using FTP in Powershell, behind a proxy?


I am attempting to use FTP in Powershell to upload a file. I am using FtpWebRequest later followed by GetRequestStream, but this method is returning an error:

“The requested FTP command is not supported when using HTTP proxy.”

I am indeed behind a proxy and required to be.

How can I upload via Powershell when behind a proxy?

This would be solely run from a .ps1 Powershell script.

I have also tried:

Where $server and that file are valid. But that code returns this error:

I also tried double backslashes in the file paths, didn’t help.

The proxy I am under only touches HTTP, and not FTP.


Are you sure your proxy supports FTP, or is it HTTP only? See this thread:

FTP File Upload with HTTP Proxy

For WebClient I’ve used this in the past although it was for HTTP use, but you could give it a try:

Note that – “The UploadFile method sends a local file to a resource. This method uses the STOR command to upload an FTP resource. For an HTTP resource, the POST method is used.”


How to upload using FTP in Powershell, behind a proxy? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply