Using FTP: Uploading File (Part 4)

by Sep 6, 2021

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

To upload a file from your local drive to an FTP server, try the code below:

$localFile = "C:\test.txt"


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

Twitter This Tip! ReTweet this Tip!