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:
CODE
I appreciate any help.
Thanks
Here is the section of my script that seems to be the issue. It does not likeAn error occurred: Exception calling "Open" with "1" argument(s): "SessionOptions.Protocol is Protocol.Sftp or Protocol.Scp, but SessionOptions.SshHostKeyFingerprint is not set."
$session = New-Object WinSCP.Session $session.Open($sessionOptions)
# Create session options for SFTP $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = $sftpServer UserName = $sftpUsername Password = $sftpPassword } # Create session and connect $session = New-Object WinSCP.Session $session.Open($sessionOptions) # Retrieve and set SSH host key fingerprint $sshHostKeyFingerprint = $session.SessionOptions.HostKey.ToString() $sessionOptions.SshHostKeyFingerprint = $sshHostKeyFingerprint # Set transfer options to download only zip files $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.FileMask = "*.zip"
Thanks