Simple PowerShell script. It downloads a file (in binary) with no issues. I need it in ascii.
$File = "c:\temp\ftpfile.txt"
$ftp = "ftp://myusername:[email protected]/'report'";
$webclient = New-Object -TypeName System.Net.WebClient;
$uri = New-Object -TypeName System.Uri -ArgumentList $ftp;
$webclient.DownloadFile($uri, $File);
The
WebClientdoes not support ascii/text FTP mode.Use
FtpWebRequestinstead and set.UseBinaryto false.Reference: What's the best way to automate secure FTP in PowerShell?
Note that the
WebClientuses theFtpWebRequestinternally, but does not expose its.UseBinaryproperty.