WinSCP with Secure Credentials
I have this script running beautifully with 5.17.10 Automation to upload a file to a server.
My question is and I tried to search for this, is it possible to use a credential file with WinSCP? Either a password in secure text or by using a credential file in xml.
If so how would I add that into the script.
My question is and I tried to search for this, is it possible to use a credential file with WinSCP? Either a password in secure text or by using a credential file in xml.
If so how would I add that into the script.
#Load WinSCP .NET assembly Add-Type -Path "C:\local path\WinSCPnet.dll" # Set up session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = "host or IP address" UserName = "username" Password = "password" SshHostKeyFingerprint = "" } $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) # Transfer files $session.PutFiles("C:\\localFile.csv", "/remote directory/*").Check() } finally { $session.Dispose() }