Re: Reading Password from File as Secure String
SessionOptions.Password is s string property, so cannot set it's value using some secure string object.
Sorry, no idea what Read-EncString does. Google does not give any results.
Connection has been unexpectedly closed. Server sent command exit status 0.
# Setup session options
$SessionOptions = New-Object WinSCP.SessionOptions
$SessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$SessionOptions.HostName = $FTPHost
$SessionOptions.UserName = $FTPUser
$SessionOptions.Password = Read-EncString $ENCFILE
#$SessionOptions.Password = "[thepasswordintext]" # This line works
$SessionOptions.SshHostKey = $SshHostKey