OK, it's about a time you switch from a plain WinSCP script to PowerShell script with use of WinSCP .NET assembly.
See
https://winscp.net/eng/docs/library_from_script
https://winscp.net/eng/docs/library_example_recursive_download_custom_error_handling
See
https://winscp.net/eng/docs/library_from_script
https://winscp.net/eng/docs/library_example_recursive_download_custom_error_handling