stop on BITS download errors
reject 0 byte dsa-collector.exe before launching
This commit is contained in:
@@ -203,9 +203,9 @@ Function Download-File {
|
||||
$URI = Get-AbsoluteURI -URL $URL
|
||||
If ( $null -eq $URI ) { Return }
|
||||
If ( [string]::IsNullOrEmpty($File) ) { $File = '{0}{1}' -f (Get-TempPath), (Split-Path $URI -Leaf) }
|
||||
#Try { (New-Object System.Net.WebClient).DownloadFile($URI,$File) }
|
||||
Try { Start-BitsTransfer -Source $URI -Destination $File }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
# BITS errors must stop the caller instead of returning a failed download's path.
|
||||
Try { Start-BitsTransfer -Source $URI -Destination $File -ErrorAction Stop }
|
||||
Catch { Throw "BITS download failed from ${URI} to ${File}: $($_.Exception.Message)" }
|
||||
Return $File
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user