With Powershell we can do FTP transaction really easy. The best feature from Powershell is we can use any dll library in our script, we can import .Net libraries and etc into our script. The script below is simple FTP to upload file to FTP server. In this script I’m using System.Net.WebClient to handle the file transfer.
1 2 3 4 5 6 7 8 9 10 11 | $ftpuser = "user" $ftppass = "12345" $ftpserver = "localhost" $file = "C:\test.txt" $filenewname = "test.txt" $webclient = New-Object System.Net.WebClient $ftp = "ftp://"+$ftpuser+":"+$ftppass+"@"+$ftpserver+"/"+$filenewname $uri = New-Object System.Uri($ftp) $webclient.UploadFile($uri,$file) |
What people search:
- powershell ftp upload
- powershell ftp
- powershell webclient ftp
- powershell script ftp upload
- system net webclient powershell ftp