Powershell FTP upload

#Cmetro-powershell-logoonfigure the folder where the files are which should be uploaded
$Directory=”C:\MyFolder”

#FTP server configuration
$ftpserver = “ftp://myftpserver.myurl.com/optionalpath/”
$username = “FTPUSER”
$password = “FTPPASS”

$webclient = New-Object System.Net.WebClient

$webclient.Credentials = New-Object System.Net.NetworkCredential($username,$password)

#Copy each file which type is *.tx*
foreach($file in (dir $Directory “*.tx*”)){
“Uploading $file…”
$uri = New-Object System.Uri($ftpserver+$file.Name)
$webclient.UploadFile($uri, $file.FullName)
}

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments