I have a known-good PowerShell script which uses the WinSCP .NET component. I added a new function to move successfully uploaded files to an archive folder, and it blew-up on me. I think I have identified the problem, related to the
NewerOnly
parameter. I have listed the pertinent commands below; I skipped all the other stuff but I can post more detail if you're unable to recreate the problem.
$Session.AddRawConfiguration("Interface\CopyParam\NewerOnly","1")
$TransferResult = $Session.PutFiles("$($Transfer[0])", "$($Transfer[1])", $DeleteAfterTransfer, $transferOptions)
$FilesToArchive = Get-ChildItem $TransferResult.Transfers.FileName
The problem occurs when there are files in the local source dir but they are skipped because they already exist in the remote target (the
NewerOnly
Session option). In this situation I am expecting the
.Transfers.Filename
method to return a null – but instead it returned the contents of the current script directory. So my testing resulted in the upload script etc all being moved into the upload-file archive; oops
Can you verify if this is a bug in the
Transfers
and/or
Filename
method?
Is there a better way for me to check which files were, in fact, transferred?
Thank you for your assistance.