Post a reply

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



The issue has somehow resolved itself. Thank-you for your help anyway.


Re: Get successful upload response even when transfer is unsuccessful

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Get successful upload response even when transfer is unsuccessful


I have a script that uploads to an SFTP server. The server it is uploading to is filename driven, meaning that if it receives a file that is an incorrect filename to what it is expecting it automatically rejects it. For some reason winscp is reporting success even if the transfer was in fact unsuccessful due to me purposely sending a file with the wrong filename, so when I log into the SFTP server as expected the file is not there. Does anyone have any idea what the issue could be?

Please see code:

write-host "Trying"
# Connect
write-host "connected"

# Upload files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.PutFiles($FullPath, "/inbox/", $False, $transferOptions)
write-host "pushed files"

# Throw on any error
write-host "error check"

# Print results
foreach ($transfer in $transferResult.Transfers)
# Success or error?
if ($transfer.Error -eq $Null)
$errortest = $transfer | out-string
$errortest2 = $transferResult | out-string
$errortest3 = $transferResult.Transfers | out-string

Write-Host $errortest
Write-Host $errortest2
Write-Host $errortest3

Write-Host ("Upload of {0} succeeded" -f $transfer.FileName)
Move-Item $FullPath $MovedFolder -force

Write-Host ("Upload of {0} failed: {1}" -f
$transfer.FileName, $transfer.Error.Message)
# Disconnect, clean up
write-host "session disposed"

exit 0

catch [Exception]
write-host "In the catch"
Write-Host ("Error: {0}" -f $_.Exception.Message)
exit 1