diff --git a/.github/scripts/install-dbatools-library.ps1 b/.github/scripts/install-dbatools-library.ps1 index 155ffa315b1..83f87d272bb 100644 --- a/.github/scripts/install-dbatools-library.ps1 +++ b/.github/scripts/install-dbatools-library.ps1 @@ -124,7 +124,11 @@ function Install-FromGitHubRelease { # Download the release Write-Log "Downloading to: $downloadPath" + # IWR is crazy slow for large downloads + $currentProgressPref = $ProgressPreference + $ProgressPreference = "SilentlyContinue" Invoke-WebRequest -Uri $releaseUrl -OutFile $downloadPath -ErrorAction Stop + $ProgressPreference = $currentProgressPref # Extract the archive Write-Log "Extracting to: $extractPath" diff --git a/private/functions/Invoke-TlsWebRequest.ps1 b/private/functions/Invoke-TlsWebRequest.ps1 index 9bde9da27f9..65c90077a47 100644 --- a/private/functions/Invoke-TlsWebRequest.ps1 +++ b/private/functions/Invoke-TlsWebRequest.ps1 @@ -14,7 +14,11 @@ function Invoke-TlsWebRequest { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor $_ } + # IWR is crazy slow for large downloads + $currentProgressPref = $ProgressPreference + $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest @Args + $ProgressPreference = $currentProgressPref [Net.ServicePointManager]::SecurityProtocol = $currentVersionTls } \ No newline at end of file diff --git a/public/Save-DbaKbUpdate.ps1 b/public/Save-DbaKbUpdate.ps1 index 8f5636169db..80359caeae2 100644 --- a/public/Save-DbaKbUpdate.ps1 +++ b/public/Save-DbaKbUpdate.ps1 @@ -144,19 +144,9 @@ function Save-DbaKbUpdate { if ((Get-Command Start-BitsTransfer -ErrorAction Ignore)) { Start-BitsTransfer -Source $link -Destination $file } else { - # IWR is crazy slow for large downloads - $currentVersionTls = [Net.ServicePointManager]::SecurityProtocol - $currentSupportableTls = [Math]::Max($currentVersionTls.value__, [Net.SecurityProtocolType]::Tls.value__) - $availableTls = [enum]::GetValues('Net.SecurityProtocolType') | Where-Object { $_ -gt $currentSupportableTls } - $availableTls | ForEach-Object { - [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor $_ - } - Write-Progress -Activity "Downloading $fileName" -Id 1 - (New-Object Net.WebClient).DownloadFile($link, $file) + Invoke-TlsWebRequest -Uri $link -OutFile $file -ErrorAction Stop Write-Progress -Activity "Downloading $fileName" -Id 1 -Completed - - [Net.ServicePointManager]::SecurityProtocol = $currentVersionTls } if (Test-Path -Path $file) { Get-ChildItem -Path $file diff --git a/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 b/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 index 0559228ffb5..c5d0da997c4 100644 --- a/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 +++ b/tests/Get-DbaEstimatedCompletionTime.Tests.ps1 @@ -30,7 +30,7 @@ Describe $CommandName -Tag IntegrationTests -Skip:$((-not $TestConfig.BigDatabas $PSDefaultParameterValues["*-Dba*:EnableException"] = $true if (-not (Test-Path -Path $TestConfig.BigDatabaseBackup) -and $TestConfig.BigDatabaseBackupSourceUrl) { - Invoke-WebRequest -Uri $TestConfig.BigDatabaseBackupSourceUrl -OutFile $TestConfig.BigDatabaseBackup -ErrorAction Stop + Invoke-TlsWebRequest -Uri $TestConfig.BigDatabaseBackupSourceUrl -OutFile $TestConfig.BigDatabaseBackup -ErrorAction Stop } $splatRestore = @{ SqlInstance = $TestConfig.instance2 diff --git a/tests/Install-DbaDarlingData.Tests.ps1 b/tests/Install-DbaDarlingData.Tests.ps1 index 243eb2bb739..eb5455115f1 100644 --- a/tests/Install-DbaDarlingData.Tests.ps1 +++ b/tests/Install-DbaDarlingData.Tests.ps1 @@ -80,7 +80,7 @@ Describe $CommandName -Tag IntegrationTests -Skip:$env:appveyor { $server.Query("CREATE DATABASE $darlingDbLocalFile") $outfile = "$tempDir\DarlingData-main.zip" - Invoke-WebRequest -Uri "https://github.com/erikdarlingdata/DarlingData/archive/main.zip" -OutFile $outfile + Invoke-TlsWebRequest -Uri "https://github.com/erikdarlingdata/DarlingData/archive/main.zip" -OutFile $outfile $resultsLocalFile = Install-DbaDarlingData -SqlInstance $TestConfig.instance3 -Database $darlingDbLocalFile -Branch main -LocalFile $outfile -Force # We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings. diff --git a/tests/Install-DbaFirstResponderKit.Tests.ps1 b/tests/Install-DbaFirstResponderKit.Tests.ps1 index bcbbc844344..71b71c2fa69 100644 --- a/tests/Install-DbaFirstResponderKit.Tests.ps1 +++ b/tests/Install-DbaFirstResponderKit.Tests.ps1 @@ -89,7 +89,7 @@ Describe $CommandName -Tag IntegrationTests { $server.Query("CREATE DATABASE $database") $outfile = "$tempDir\SQL-Server-First-Responder-Kit-main.zip" - Invoke-WebRequest -Uri "https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/archive/main.zip" -OutFile $outfile + Invoke-TlsWebRequest -Uri "https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/archive/main.zip" -OutFile $outfile $resultsLocalFile = Install-DbaFirstResponderKit -SqlInstance $TestConfig.instance3 -Database $database -Branch main -LocalFile $outfile -Force # We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings. diff --git a/tests/Install-DbaMultiTool.Tests.ps1 b/tests/Install-DbaMultiTool.Tests.ps1 index 7abde9c490a..19609949ff4 100644 --- a/tests/Install-DbaMultiTool.Tests.ps1 +++ b/tests/Install-DbaMultiTool.Tests.ps1 @@ -89,7 +89,7 @@ Describe $CommandName -Tag IntegrationTests { $null = New-Item -Type Container -Path $tempDir $outfile = "$tempDir\dba-multitool-$branch.zip" - Invoke-WebRequest -Uri "https://github.com/LowlyDBA/dba-multitool/archive/$branch.zip" -OutFile $outfile + Invoke-TlsWebRequest -Uri "https://github.com/LowlyDBA/dba-multitool/archive/$branch.zip" -OutFile $outfile $resultsLocalFile = Install-DbaMultiTool -SqlInstance $TestConfig.instance3 -Database $database -Branch $branch -LocalFile $outfile -Force # We want to run all commands outside of the BeforeAll block without EnableException to be able to test for specific warnings.