Adding a failover for the ISO download

This commit is contained in:
Chris Long
2020-03-23 22:51:43 -07:00
parent 5dcc9965d3
commit 242e1a7cf3

View File

@@ -49,7 +49,14 @@ if (-not (Test-Path "C:\Program Files\Microsoft Advanced Threat Analytics\Center
$actualHash = (Get-FileHash -Algorithm SHA256 -Path "$env:temp\$title.iso").Hash
If (-not ($actualHash -eq $fileHash))
{
throw "$title.iso was not downloaded correctly: hash from downloaded file: $actualHash, should've been: $fileHash"
Write-Host "$title.iso was not downloaded correctly: hash from downloaded file: $actualHash, should've been: $fileHash. Re-trying using BitsAdmin now..."
}
Remove-Item -Path "$env:temp\$title.iso" -Force
bitsadmin /Transfer ATA $downloadUrl "$env:temp\$title.iso"
$actualHash = (Get-FileHash -Algorithm SHA256 -Path "$env:temp\$title.iso").Hash
If (-not ($actualHash -eq $fileHash))
{
throw "$title.iso was not downloaded correctly after a retry: hash from downloaded file: $actualHash, should've been: $fileHash - Giving up."
}
}
$Mount = Mount-DiskImage -ImagePath "$env:temp\$title.iso" -StorageType ISO -Access ReadOnly -PassThru