I’m uploading a file with WinSCP from PowerShell. The script reaches its success message, but the remote file does not appear or change. Manual uploads work, and the account may have limited permissions. What should I check?
Why does my WinSCP script say the upload worked when no file shows up?
Answers
Check the second argument to PutFiles. That argument is the remote destination path, and the value .\ may not mean the directory you expect on the SFTP server. In the case described, changing it to /* fixed the transfer. Treat that as a clue, not a universal path: use the remote path syntax and directory that match your server, and verify where the file lands.
Also check that the remote destination is a directory the account can write to. A path that looks like a local Windows path is not necessarily meaningful on the remote server.
Reply to this answer
Separate the transfer result from your own success message. Log the session, inspect the transfer result and its failures, and print a success line only when a transfer is actually listed. An empty transfer list can otherwise leave you with no useful confirmation, while Check() should surface reported transfer failures.
And upload-only permissions can explain why delete, rename, or move operations fail, but they do not by themselves explain a missing upload. Confirm the exact remote directory and filename with the server administrator if the path still looks right.
Reply to this answer
One small mismatch in the sample is worth checking: it creates query.csv but uploads data.csv. Make sure the file you intend to send is the one named in PutFiles, and that it exists before the transfer starts. That won’t fix a bad remote path, but it can make debugging confusing.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions