Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP Download Multiple Files using PowerShell

I’m new to PowerShell and am trying to convert a batch file that downloads multiple files based on names and extension from a directory on an ftp site. While I’ve found several examples that download a file, I’m struggling to find one that shows how to download multiple files. In a batch I can quite simply use the ftp.exe and the mget command with wildcards??

Can someone please point me in the right direction.

Thanks in advance. John

like image 271
John E Avatar asked Apr 09 '26 21:04

John E


2 Answers

There are multiple ways to achieve this. One is to use the System.Net.FtpWebRequest as shown in this example: http://www.systemcentercentral.com/BlogDetails/tabid/143/IndexID/81125/Default.aspx

Or there are /n Software NetCmdlets you can use:

http://www.nsoftware.com/powershell/tutorials/FTP.aspx

like image 89
ravikanth Avatar answered Apr 11 '26 21:04

ravikanth


In a batch I can quite simply use the ftp.exe and the mget command with wildcards??

You can do the same in Powershell if you want to.

For a more Powershell way, you can use the FTPWebRequest. See here: http://msdn.microsoft.com/en-us/library/ms229711.aspx. You can build on the example to download multiple files in a loop.

But bottomline is, you do not have to convert something you have in batch to Powershell. You can, if you want, but what you have in batch, especially when calling external programs, should work just as well.

like image 45
manojlds Avatar answered Apr 11 '26 23:04

manojlds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!