Hi all
we need to made a script to send a file csv from Windows server 2016 to ubuntu server 18. On ubuntu, try to install vsftpd and from windows (Filezilla software) we can access. But when try to send file, an error showed.
Script used:
$Dir="C:\Scripts" #ftp server $ftp = "ftp://ipmachine/folder/" $user = "username" $pass = "password" | ConvertTo-SecureString -AsPlainText -Force $webclient = New-Object System.Net.WebClient $webclient.Credentials = New-Object System.Net.NetworkCredential($user,$pass) #send file foreach($item in (dir $Dir "*.csv")){ "Uploading $item..." $uri = New-Object System.Uri($ftp+$item.Name) $webclient.UploadFile($uri, $item.FullName) }
But recieve this error:
Exception calling "UploadFile" with "2" argument(s): "Unable to connect to the remote server"At line:17 char:5
+ $webclient.UploadFile($uri, $item.FullName)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
Also we tryed to use powershell 6. and SSH connection, but is no possible on our infraestructure.
Some idea?
Thanks and regards,
Gerardo,