.NET PowerShell script - assist with improving upload resilience
Hello,
First time here, although long time WinSCP user.
I've been using PowerShell and the WinSCP .NET functionality to do the bulk of my scripting and automation of SFTP file uploads and downloads, mostly with fantastic results.
I'm currently trying to troubleshoot and improve a situation whereby reasonably large file uploads of zip files (100–300 Megabytes) are occasionally resulting either in those files only being partially uploaded (i.e. file size smaller than the original) or the file seeming to upload fully and the file sizes matching, but the uploaded file is corrupted in some way as I cannot uncompress it.
I tried to make use of the
I've seen quite a few examples of PowerShell code using .NET WinSCP and calling the
What I want is to improve the resilience of my script so that if for whatever reason a given file does NOT complete uploading, my script can 'tell' that has occurred and can essentially 'try again' until it HAS confirmed the file is properly transferred and then and ONLY then move onto the next file to process.
I feel embarrassed to ask for any code examples, but it would be much appreciated. I want to verify transfers before moving on to the next file, thank you.
First time here, although long time WinSCP user.
I've been using PowerShell and the WinSCP .NET functionality to do the bulk of my scripting and automation of SFTP file uploads and downloads, mostly with fantastic results.
I'm currently trying to troubleshoot and improve a situation whereby reasonably large file uploads of zip files (100–300 Megabytes) are occasionally resulting either in those files only being partially uploaded (i.e. file size smaller than the original) or the file seeming to upload fully and the file sizes matching, but the uploaded file is corrupted in some way as I cannot uncompress it.
I tried to make use of the
Session.CalculateFileChecksum
method, but unfortunately the remote SFTP server I am dealing with must not support it. I have downloaded the remote parties' copy of the offending zip file and used PowerShell to run a file hash comparison and sure enough, the two files are different, despite the file size being identical.
I've seen quite a few examples of PowerShell code using .NET WinSCP and calling the
Check
result of a transfer object as it iterates through files to upload/download, but I must admit I'm sometimes a bit confused by the overall syntax.
What I want is to improve the resilience of my script so that if for whatever reason a given file does NOT complete uploading, my script can 'tell' that has occurred and can essentially 'try again' until it HAS confirmed the file is properly transferred and then and ONLY then move onto the next file to process.
I feel embarrassed to ask for any code examples, but it would be much appreciated. I want to verify transfers before moving on to the next file, thank you.