winscp automation using powershell
I am trying to automate a process which involves copying a file from a windows share to a redhat linux 7.2 server. I am using power shell for this and attached is the script (Automation-CSV-FTP-Moodle-Emrollments QA). When I runt the script it is breaking at the open session with error . The same script executes ok the QA server. I checked that firewalld is dead. No iptables.
Any ideas please . I am running this scrip on my machine and I can connect manually using winscp to the same server with no issues.
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.
Authentication log (see session log for details):
Using username "root".
Authentication failed."
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:28 char:1
+ $session.Open($sessionOptions)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException
Exception calling "PutFiles" with "4" argument(s): "Session is not opened"
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:38 char:1
+ $session.PutFiles("$SourceSuspendOldPath", "$DestinationSuspendOldPat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "PutFiles" with "4" argument(s): "Session is not opened"
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:43 char:1
+ $session.PutFiles("$SourceTodayPath", "$DestinationTodayPath", $False ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
error log : tail -f /var/log/secure
Jun 29 11:32:01 xxxxxxx sshd[23287]: error: Received disconnect from xxxxxxxxxx: 13: Unable to authenticate [preauth]
Any ideas please . I am running this scrip on my machine and I can connect manually using winscp to the same server with no issues.
Exception calling "Open" with "1" argument(s): "Connection has been unexpectedly closed. Server sent command exit status 0.
Authentication log (see session log for details):
Using username "root".
Authentication failed."
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:28 char:1
+ $session.Open($sessionOptions)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SessionRemoteException
Exception calling "PutFiles" with "4" argument(s): "Session is not opened"
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:38 char:1
+ $session.PutFiles("$SourceSuspendOldPath", "$DestinationSuspendOldPat ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "PutFiles" with "4" argument(s): "Session is not opened"
At D:\Automation-CSV-FTP-Moodle-Emrollments LMS.ps1:43 char:1
+ $session.PutFiles("$SourceTodayPath", "$DestinationTodayPath", $False ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
error log : tail -f /var/log/secure
Jun 29 11:32:01 xxxxxxx sshd[23287]: error: Received disconnect from xxxxxxxxxx: 13: Unable to authenticate [preauth]