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.

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: Powershell: No way to disable reconnect

Setting the reconnecttime to off actually enables infinite reconnects:
Quite the opposite of what you want. You want to set the option to a low value (like one second). Though there's currently no way to turn it off completely (neither in scripting, nor in .NET assembly). If your server is still running, WinSCP will likely manage to reconnect even within the one second limit.

I've added a request for this to the tracker:
Issue 1981 – Allow disabling automatic reconnects in automation
You can vote for it there.

PowerShell: No way to disable reconnect


there are a lot of postings here about how to avoid automatic reconnect. Some of the postings say, one has to user the option "reconnect". But as you can see in documentation, in PowerShell it's only possible to set a TimeSpan and it is not possible to set the option to off, like in batch mode. I tried many ways to get it somehow to work, but it did not (even tried AdditionalExecutableArguments, which always should be null). Here is my testcase using SFTP to a Ubuntu Server that I'm able to control:
The script first opens the connection and than waits for user input. I can see on the server auth.log the process id under which the connection is opened. Than, on server side, I kill all processes of the user (sudo killall -u <username goes here>)
I then go back to the script and do the input, so it continues. I can see, that it is doing a reconnect.
Read-Host "Script waiting. Press enter to go on"
$transferResult = $session.PutFiles($localPath, $remotePath, $false, $transferOptions)

So how to switch off reconnects using PowerShell?