Session Open Command Is Failing

Advertisement

aksarben
Joined:
Posts:
68

Session Open Command Is Failing

I’m writing a PowerShell script for WinSCP automation, and it’s failing on the session.open(). The code:
$sessionOptions
 
$session.open($sessionOptions)   # Connect to server
The content of $sessionOptions:
Name                                         : Dick@Solomon
Protocol                                     : Sftp
HostName                                     : Solomon
PortNumber                                   : 0
UserName                                     : Dick
Password                                     : xxx [masked for security]
SecurePassword                               : System.Security.SecureString
NewPassword                                  : 
SecureNewPassword                            : 
Timeout                                      : 00:00:15
TimeoutInMilliseconds                        : 15000
PrivateKeyPassphrase                         : 
SecurePrivateKeyPassphrase                   : 
RootPath                                     : 
Secure                                       : False
SshHostKeyFingerprint                        : 
SshHostKeyPolicy                             : Check
GiveUpSecurityAndAcceptAnySshHostKey         : False
SshPrivateKeyPath                            : 
SshPrivateKey                                : 
SshPrivateKeyPassphrase                      : 
FtpMode                                      : Passive
FtpSecure                                    : None
WebdavSecure                                 : False
WebdavRoot                                   : 
TlsHostCertificateFingerprint                : 
GiveUpSecurityAndAcceptAnyTlsHostCertificate : False
TlsClientCertificatePath                     :
The error message:
Write-Error: Exception calling "Open" with "1" argument(s): "Method not found: 'Void System.Threading.EventWaitHandle..ctor(Boolean, System.Threading.EventResetMode, System.String, Boolean ByRef, System.Security.AccessControl.EventWaitHandleSecurity)'."
What am I doing wrong?

Reply with quote

Advertisement

aksarben
Joined:
Posts:
68

Got Correct .NET Assembly (I Think)

I re-read the doc page another 2-3 times, and I think I finally understand what you were saying.

Anyway, I changed my WINSCP_PATH environment variable to point to the newly installed DLL in the netstandard2.0 folder, and re-launched my PowerShell script.

I no longer get the message about the bad constructor arguments. Now I get a different error message (which I is assume is good news, because it indicates I have a different DLL).

The new error message:
Write-Error: Exception calling "Open" with "1" argument(s): "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set."
I'm trying to connect to an OpenSSH server on my PC for testing. Where do I get the SshHostKeyFingerprint the message refers to?

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum