Tuesday, April 3, 2012

Download a file from an ftp server in powershell


Define the file you’d like to download and where to save:

$ftpfile = "ftp://ftp.adobe.com/pub/adobe/reader/win/10.x/10.1.2/en_US/AdbeRdr1012_en_US.exe"
$localfile = "C:\temp\AdbeRdr1012_en_US.exe"

Create new-objects. Click on the corresponding links to get information about “system.net.webclient” and “system.uri

$ftpclient = New-Object system.Net.WebClient
$uri = New-Object System.Uri($ftpfile)

And finally, download the file:

$ftpclient.DownloadFile($uri,$localfile)

3 comments: