Ignore errors when downloading

Advertisement

sendo
Joined:
Posts:
4

Ignore errors when downloading

Hi guys,
Sorry if i missed something but does anyone know how to ignore errors when downloading ?
I have to download multiple files but the operation failed beacause i don't have permissions to access some files.
So i'm looking for a "continue with next" option
I tried to set ContinueOnError or PreserveReadOnly
I also tried :
try
{
 $transferResult = $Session.GetFiles($remotePath, $localPath, $false, $transferOptions)
}
catch {}    

but the exception still raise and seem to be uncatchable.
Any ideas ?
(I'm using the last build with powershell)

Thanks

Reply with quote

sendo
Joined:
Posts:
4

too bad, batch continue option seems to be unsupported, so i will call getfiles for each file with something like that :


$excludeDir='|*/'
$directory = $session.ListDirectory("$remotePath")
foreach ($file in $directory.Files | where {-not $_.IsDirectory})
{
foreach ($f in $file)
{
$transferOptions.FileMask = $f.Name + $excludeDir
$transfer = $Session.GetFiles($remotePath, $localPath, $false, $transferOptions)
if ($transfer.Transfers.Error) {Write-Host ("{0} : {1}" -f $transfer.Transfers.FileName, $transfer.Transfers.Error) -ForegroundColor Red
}
}

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,226
Location:
Prague, Czechia

sendo wrote:

too bad, batch continue option seems to be unsupported, so i will call getfiles for each file with something like that
That's the correct way.
_________________
Martin Prikryl

Reply with quote

Advertisement

You can post new topics in this forum