Invoke-WebRequest throws an exception when the download fails, so we
should use try-catch instead of status code to check failure. We can use
the generic Retry function from tools.ps1 to do this.
In addition pass -PassThru to avoid leaving a corrupted download file in
case the download fails. This will buffer the download and write it once
at the end.
Fix #57196