diff --git a/images/macos/scripts/helpers/Common.Helpers.psm1 b/images/macos/scripts/helpers/Common.Helpers.psm1 index 359f5974ee32..57e84aa09ea5 100644 --- a/images/macos/scripts/helpers/Common.Helpers.psm1 +++ b/images/macos/scripts/helpers/Common.Helpers.psm1 @@ -84,7 +84,7 @@ function Invoke-DownloadWithRetry { for ($retries = 20; $retries -gt 0; $retries--) { try { $attemptStartTime = Get-Date - (New-Object System.Net.WebClient).DownloadFile($Url, $Path) + Invoke-WebRequest -Uri $Url -Outfile $Path $attemptSeconds = [math]::Round(($(Get-Date) - $attemptStartTime).TotalSeconds, 2) Write-Host "Package downloaded in $attemptSeconds seconds" break diff --git a/images/ubuntu/scripts/helpers/Common.Helpers.psm1 b/images/ubuntu/scripts/helpers/Common.Helpers.psm1 index 75dcdb7457f7..0fef1e3a164b 100644 --- a/images/ubuntu/scripts/helpers/Common.Helpers.psm1 +++ b/images/ubuntu/scripts/helpers/Common.Helpers.psm1 @@ -133,7 +133,7 @@ function Invoke-DownloadWithRetry { for ($retries = 20; $retries -gt 0; $retries--) { try { $attemptStartTime = Get-Date - (New-Object System.Net.WebClient).DownloadFile($Url, $DestinationPath) + Invoke-WebRequest -Uri $Url -Outfile $DestinationPath $attemptSeconds = [math]::Round(($(Get-Date) - $attemptStartTime).TotalSeconds, 2) Write-Host "Package downloaded in $attemptSeconds seconds" break diff --git a/images/windows/scripts/helpers/InstallHelpers.ps1 b/images/windows/scripts/helpers/InstallHelpers.ps1 index 67faade1d2a5..396ad4d51e09 100644 --- a/images/windows/scripts/helpers/InstallHelpers.ps1 +++ b/images/windows/scripts/helpers/InstallHelpers.ps1 @@ -184,7 +184,7 @@ function Invoke-DownloadWithRetry { for ($retries = 20; $retries -gt 0; $retries--) { try { $attemptStartTime = Get-Date - (New-Object System.Net.WebClient).DownloadFile($Url, $Path) + Invoke-WebRequest -Uri $Url -Outfile $Path $attemptSeconds = [math]::Round(($(Get-Date) - $attemptStartTime).TotalSeconds, 2) Write-Host "Package downloaded in $attemptSeconds seconds" break