Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Send csv file from server 2016 to ubuntu 18 via powershell

$
0
0

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,


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>