A few days ago I was working in a project and I had the following situation: I had some SQL server profiler trace files (more than 50), every trace file was around 300MB and I needed to upload all files to an ftp server. Internet connection was not good and I tried to upload a single file and it took a lot of time to upload it. So, I decided to develop a PowerShell script in order to automatize this task, I was not willing to stay in front of the computer uploading all files by hand one by one. I ran this script during the night and the next morning all files were uploaded successfully. Here is the script, I hope you’ll find it useful.

#we specify the directory where all files that we want to upload are contained 
#ftp server
$ftp = "ftp://ftp.server.com/dir/"
$user = "user"
$pass = "Pass"
$webclient = New-Object System.Net.WebClient 
$webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass)  
#list every sql server trace file
foreach($item in (dir $Dir "*.trc")){ 
"Uploading $item..."
$uri = New-Object System.Uri($ftp+$item.Name) 
$webclient.UploadFile($uri, $item.FullName)