Skip to content

Commit

Permalink
Merge pull request #2231 from microsoft/dpaul-UpdateOnlyException
Browse files Browse the repository at this point in the history
Allow exceptions to be displayed for ScriptUpdateOnly param
  • Loading branch information
dpaulson45 authored Nov 27, 2024
2 parents 480d781 + 706e225 commit 293e235
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Diagnostics/HealthChecker/HealthChecker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,23 @@ begin {

if ($ScriptUpdateOnly) {
Invoke-SetOutputInstanceLocation -FileName "HealthChecker-ScriptUpdateOnly"
$currentErrors = $Error.Count
switch (Test-ScriptVersion -AutoUpdate -VersionsUrl "https://aka.ms/HC-VersionsUrl" -Confirm:$false) {
($true) { Write-Green("Script was successfully updated.") }
($false) { Write-Yellow("No update of the script performed.") }
default { Write-Red("Unable to perform ScriptUpdateOnly operation.") }
}

if ($currentErrors -ne $Error.Count) {
Write-Host ""
Write-Warning "Failed to get latest version of script details. Failing with this inner exception:"
Write-Host ""
$Error[$Error.Count - $currentErrors - 1] | Out-String | Write-Host -ForegroundColor Red
Write-Host ""
Write-Host "Address the above exception in order to get the script to auto update."
}

Invoke-ErrorCatchActionLoopFromIndex $currentErrors
return
}

Expand Down

0 comments on commit 293e235

Please sign in to comment.