Post a reply

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)


Topic review


Re: Task in scheduler doesn't work properly

Please start by contacting the server administrator to get some explanation why the authentication is failing.

Task in scheduler doesn't work properly

my task in Windows Task scheduler (Windows Version 1803) doesn't cannot connect to the server in the first try but works fine afterwards.
In both cases the task is executed by a service account and none of the settings are changed. In the first try I get the error
" Connection has been unexpectedly closed. Server sent command exit status 0. Authentication log (see session log for details): Using username "USERNAME". Further authentication required
Authentication failed."
I already created two log files (one for the fail, one for the working run) and attached them (marked as private). Unfortunately I don't have access to the server.

I'm using this code in powershell:
# 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


                # Connect

                $transferOptions = New-Object WinSCP.TransferOptions
                $transferOptions.TransferMode = [WinSCP.TransferMode]::Automatic;
                $transferOptions.PreserveTimestamp = $false;
                $sychronisationResult = $session.GetFiles(

Thanks for your help.[/code]