Using FTP: Downloading File (Part 2)

by Aug 31, 2021

PowerShell does not come with cmdlets to download and upload data via FTP. However, you can use .NET for this.

To download a file from an FTP server, try using this code:

$localFile = "C:\test.txt"

$username='testuser'
$password='P@ssw0rd'

[System.Uri]$uri = "ftp://${username}:$password@192.168.1.123/test.txt"
$webclient = [System.Net.WebClient]::new()
$webclient.DownloadFile($uri, $localFile)
$webclient.Dispose()


Twitter This Tip! ReTweet this Tip!