potatoqualitee / kbupdate

🛡 KB Viewer, Saver, Installer and Uninstaller
MIT License
338 stars 50 forks source link

Create failback for Start-BitsTransfer #142

Closed potatoqualitee closed 2 years ago

potatoqualitee commented 2 years ago

hmmm i already do this


                        if ((Get-Command Start-BitsTransfer -ErrorAction Ignore)) {
                            try {
                                $null = Start-BitsTransfer -Source $link -Destination $file -ErrorAction Stop
                            } catch {
                                Write-Progress -Activity "Downloading $FilePath" -Id 1
                                $null = Invoke-TlsWebRequest -OutFile $file -Uri "$link"
                                Write-Progress -Activity "Downloading $FilePath" -Id 1 -Completed
                            }
                        } else {
                            try {
                                # IWR is crazy slow for large downloads
                                Write-Progress -Activity "Downloading $FilePath" -Id 1
                                $null = Invoke-TlsWebRequest -OutFile $file -Uri "$link"
                                Write-Progress -Activity "Downloading $FilePath" -Id 1 -Completed
                            } catch {
                                Stop-PSFFunction -EnableException:$EnableException -Message "Failure" -ErrorRecord $_ -Continue
                            }
                        }