Download multiple files from an array
I'm using powershell to script the download of multiple files. The file names are held in an array and I use a foreach loop to loop through the array. This works great as long as each file in the array is on the server, but if one of the files is not available, none of the successive files in the array are downloaded. I read https://winscp.net/eng/docs/scriptcommand_get#net and it states that I need to call
Any help on this would be greatly appreciated. This is driving me nuts.
GetFiles
for each file I'm trying to download. Can you please help me with my logic on this? Here is my code:
$GetFileMask = @("Weekly_Values*.pgp", "Monthly_Values*.pgp") # Download the files according to the file mask foreach ($file in $GetFileMask) { # Download the file and throw on any error $transferResult = $Session.GetFiles("$ServerPath$file", "$DLPATH$file") $transferResult.Check(); }