Difference between revisions of "Using Powershell for ftp"
From MyWiki
| Line 15: | Line 15: | ||
$webclient.UploadFile($uri, $File) | $webclient.UploadFile($uri, $File) | ||
| + | |||
| + | </source> | ||
| + | |||
| + | <source lang="powershell"> | ||
| + | //Download: | ||
| + | |||
| + | $File = "c:\store\somefilename.zip" | ||
| + | $ftp = "ftp://username:password@example.com/pub/outbound/somefilename.zip" | ||
| + | |||
| + | "ftp url: $ftp" | ||
| + | |||
| + | $webclient = New-Object System.Net.WebClient | ||
| + | $uri = New-Object System.Uri($ftp) | ||
| + | |||
| + | "Downloading $File..." | ||
| + | |||
| + | $webclient.DownloadFile($uri, $File) | ||
</source> | </source> | ||
Revision as of 14:34, 5 August 2015
Reference : http://stackoverflow.com/questions/936108/how-to-script-ftp-upload-and-download
//Upload: $File = "D:\Dev\somefilename.zip" $ftp = "ftp://username:password@example.com/pub/incoming/somefilename.zip" "ftp url: $ftp" $webclient = New-Object System.Net.WebClient $uri = New-Object System.Uri($ftp) "Uploading $File..." $webclient.UploadFile($uri, $File)
//Download: $File = "c:\store\somefilename.zip" $ftp = "ftp://username:password@example.com/pub/outbound/somefilename.zip" "ftp url: $ftp" $webclient = New-Object System.Net.WebClient $uri = New-Object System.Uri($ftp) "Downloading $File..." $webclient.DownloadFile($uri, $File)