In the Login-WinSCP screen, highlight the site you're connecting with/select manager/Generate Session URL.
Copy and paste to your script.
This should give you the command string along with :port
value you've defined the site with.
Hope it helps.
I know the default port for SFTP is 22, but what if the port is 2222? I am trying to write my first WinSCP script to connect to an external SFTP site for synching file folders (one they have with a local share here). I was able to use the winscp.exe gui to connect and browse the files (and get the hostkey), but need to automate this now. I have been reviewing the documentation on scripting, but have not seen the answer yet.
Ultimately this script will be run for an SSIS job which then further will use these files for data extraction, etc.
Thanks for the information.