diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 76f093b5e..e05e44e9f 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -51,23 +51,27 @@ function Install-Binary try { + $installStartTime = Get-Date Write-Host "Starting Install $Name..." $process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru - $exitCode = $process.ExitCode + $installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2) if ($exitCode -eq 0 -or $exitCode -eq 3010) { - Write-Host "Installation successful" + Write-Host "Installation successful in $installCompleteTime seconds" } else { Write-Host "Non zero exit code returned by the installation process: $exitCode" + Write-Host "Total time elapsed: $installCompleteTime seconds" exit $exitCode } } catch { + $installCompleteTime = [math]::Round(($(Get-Date) - $installStartTime).TotalSeconds, 2) Write-Host "Failed to install the $fileExtension ${Name}: $($_.Exception.Message)" + Write-Host "Installation failed after $installCompleteTime seconds" exit 1 } } @@ -178,24 +182,29 @@ function Start-DownloadWithRetry } $filePath = Join-Path -Path $DownloadPath -ChildPath $Name - - #Default retry logic for the package. + $downloadStartTime = Get-Date + + # Default retry logic for the package. while ($Retries -gt 0) { try { + $downloadAttemptStartTime = Get-Date Write-Host "Downloading package from: $Url to path $filePath ." (New-Object System.Net.WebClient).DownloadFile($Url, $filePath) break } catch { - Write-Host "There is an error during package downloading:`n $_" + $failTime = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2) + $attemptTime = [math]::Round(($(Get-Date) - $downloadAttemptStartTime).TotalSeconds, 2) + Write-Host "There is an error encounterd after $attemptTime seconds during package downloading:`n $_" $Retries-- if ($Retries -eq 0) { Write-Host "File can't be downloaded. Please try later or check that file exists by url: $Url" + Write-Host "Total time elapsed $failTime" exit 1 } @@ -204,6 +213,8 @@ function Start-DownloadWithRetry } } + $downloadCompleteTime = [math]::Round(($(Get-Date) - $downloadStartTime).TotalSeconds, 2) + Write-Host "Package downloaded successfully in $downloadCompleteTime seconds" return $filePath }