Re: Task in scheduler doesn't work properly
Please start by contacting the server administrator to get some explanation why the authentication is failing.
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $customer.FTPSettings.server;
Portnumber = $customer.FTPSettings.portnumber;
UserName = $customer.FTPSettings.user;
SecurePassword = ConvertTo-SecureString $customer.FTPSettings.password -Key $key;
SshHostKeyFingerprint = $customer.FTPSettings.SSHKey;}
$session = New-Object WinSCP.Session
try
{
# Connect
$session.Open($sessionOptions)
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Automatic;
$transferOptions.PreserveTimestamp = $false;
$sychronisationResult = $session.GetFiles(
$downloadpath,
$repositorydirProgress,
$false,
$transferOptions
);