I am attempting to use WinSCP in a PowerShell script to connect to and retrieve files via SFTP.
However, any attempts to enumerate files in the remote directory, both via the GUI (when first connecting) or via the DLL (using
EnumerateRemoteFiles) is incredibly slow, to the point that it is making it unusable (3+ minutes for a directory containing 15K files).
Connecting to and list the content of the same server and directory using the built-in
sftp binary included in Server 2019 takes only 6 or so seconds by comparison.
I have searched the forums and seen various posts about improving speed by using the 'optimise buffer size' option, but the actual connection speed once file transfer is initiated is okay – it is just the enumeration.
I have tried toggling various options on and off, but with no improvement.
Is there any way of further debugging what is going on and any clues as to why this is the case?
Many thanks in advance.