Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Using ChilkatDotNet2.dll to connect to sftp server in PS script. Fails when automatically run, succeeds when run manually.

$
0
0

I didn't actually write this script and have no actual idea what ChilkatDotNet2.dll is, other then some kind of SFTP library.  The script uses it to connect to a server, and then authenticate the user, then it's supposed to upload some files to the SFTP server.

anyway, whether it succeeds or fails, it sends an e-mail letting us know what happened.  if it failed, it also gives us exception information.  Here is the part of the script I'm having trouble with.

$tryCount = 0

do { $successCon = $sftp.Connect($sftpHostname,$sftpPort) if ($successCon -eq $true){ $successAuth = $sftp.AuthenticatePw($sftpUser,$sftpPass) if ($successAuth -ne $true){ $sftp.Disconnect() } } $tryCount++ } while(($successCon -ne $true -or $successAuth -ne $true) -and $tryCount -le 3)


$successCon is $true but $successAuth is $false.

$sftp is a new Chilkat.SFtp object at this point.  The other variables contain things like the username and password and server information.  the script succeeds when we run it manually but fails when it automatically runs.  can anyone give me any hints as to why?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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