I’m not sure if this is a Bug or I am missing something here. But maybe some could help me with my problem. I like to script and FTP Transfer from Powershell. So far everything works fine but not the exit codes.
For a small test I made 2 commad scripts one that works and one that will fail. When I do let them run from batch the exit codes return fine.
winscp.exe /console /script=test1.txt /log=ftp.log
winscp.exe /console /script=test2.txt /log=ftp.log
Press any key to continue . . .
But from Powershell I always get an “0” as return code.
Code of powershellscript:.\test1.ps1
.\winscp.exe /console /script=test1.txt /log=ftp.log $LASTEXITCODE .\winscp.exe /console /script=test2.txt /log=ftp.log $LASTEXITCODE
ftp.log shows following line:
Exit Codes from Powershell:. 2014-01-15 12:24:51.561 Script: Failed
. 2014-01-15 12:24:51.561 Script: Exit code: 1
. 2014-01-15 12:24:51.561 Disconnected from server
< 2014-01-15 12:24:51.567 226 Closing data connection
i tried by myself with ping and the sc command. On both the exit codes worked.
Has anyone got this working on WinSCP or does have an idea how to sovle this. (i don't want to use batch)