Reading Password from File as Secure String
I am doing some testing for some processes at work and I really like the possibility of using the .NET assembly. The issue I'm having is with the password. Our scripts are automated and the password is stored encrypted in a file. When I read the file the password is decrypted and converted to a SecureString. When I use the secure string I get an error:
but if I typed my password in the password variable, the script works fine. I'm using Powershell, is there any way to read a SecureString from disk and use it with the .NET assembly?
Here are examples of my session options:
Thanksfor the help.
Connection has been unexpectedly closed. Server sent command exit status 0.
but if I typed my password in the password variable, the script works fine. I'm using Powershell, is there any way to read a SecureString from disk and use it with the .NET assembly?
Here are examples of my session options:
# 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
Thanksfor the help.