powershellcurlftpinvoke-webrequest

How to fix curl syntax error in Windows Powershell?


I'm trying to use curl in Windows Powershell to download a file from an SFTP/FTPS site, I have tried to follow the examples in How to use curl on Windows, which seem to indicate that I can download from an SFTP/FTPS site. I do the following:

PS C:\temp> curl -User 'username:password' -Uri 'ftp://ftp.company.com/devops/path/somefile.txt' -OutFile somefile.txt

But I get the following error

curl : The remote server returned an error: (530) Not logged in.
At line:1 char:1
+ curl -User 'username:password' -Uri 'ftp://ftp.company.com/devops ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.FtpWebRequest:FtpWebRequest) [Invoke-WebRequest], W
   ebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestComma
   nd

I've also tried ideas in other Stackoverflow posts, e.g., How to use the curl command in PowerShell?, to no avail. What is my syntax error?


Solution

  • Building on the helpful comments:


    Therefore, you have two options: