PowerShell Script Error – "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOpti
Trying to automate weekly FTP transfers using a powershell script. I am getting the following error:
An error occurred: Exception calling "Open" with "1" argument(s): "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set."
Here is the section of my script that seems to be the issue. It does not like
Re: PowerShell Script Error – "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOpti
Thank you martin! I am closer. Now I am getting the following:
An error occurred: 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):
I wonder if it is because there is a banner when connecting to the site and its timing out because I cannot see the banner, therefore I cannot agree.
Re: PowerShell Script Error – "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOpti
The banner should not be a problem. Please attach a full session log file showing the problem (using the latest version of WinSCP). If you can connect anyhow (like in the GUI), please post log for that too.
To generate the session log file, set
Session.SessionLogPath
. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Re: PowerShell Script Error – "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOpti
I added the following to try and generate a log file from the PowerShell script:
Re: PowerShell Script Error – "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOpti
You have to set
Session.SessionLogPath
before opening the connection – before calling
Session.Open
. You current code throws an exception – haven't you noticed? If you haven't you probably have some bad error reporting in place.