Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: I tried the steps in this page:

I'm sorry, but you didn't tell us anything about the problems you are facing. Without any information, all I can do is to repeat everything that's written in the linked article already.
hroberts65616

I tried the steps in this page:

I tried to follow the steps in this page: https://winscp.net/eng/docs/guide_protecting_credentials_for_automation#powershell

However I am not getting it to work. I have tried it with an XML file and with a CLixml file. I can not get winscp to accept either for me to not have the password in plain text.

Im fairly new to Powershell, but have been scripting on the Linux side for many years.

Thanks all
hroberts65616

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.
#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()
}