diff --git a/start-modules/10-Module.Logging.ps1 b/start-modules/10-Module.Logging.ps1 index 34540ed8..b866d920 100644 --- a/start-modules/10-Module.Logging.ps1 +++ b/start-modules/10-Module.Logging.ps1 @@ -34,9 +34,13 @@ function Start-ToolkitLog { #> param([string]$ToolName) - # Clean up leftover transcripts + # Clean up leftover transcripts. Stop-Transcript throws when no transcript is + # active ("The host is not currently transcribing"), which is expected on a + # fresh run, so that benign case is silenced instead of surfaced as a warning. try { Stop-Transcript -ErrorAction SilentlyContinue } catch { - Write-Warning "start-modules\10-Module.Logging.ps1, Start-ToolkitLog: $($_.Exception.Message)" + if ($_.Exception.Message -notmatch 'not currently transcribing') { + Write-Warning "start-modules\10-Module.Logging.ps1, Start-ToolkitLog: $($_.Exception.Message)" + } } $dateTime = Get-Date -Format "yyyy-MM-dd_HH-mm-ss" diff --git a/start-modules/90-Skeleton.Main.ps1 b/start-modules/90-Skeleton.Main.ps1 index 3c113969..235f60f0 100644 --- a/start-modules/90-Skeleton.Main.ps1 +++ b/start-modules/90-Skeleton.Main.ps1 @@ -30,6 +30,15 @@ function Invoke-WinToolkitSetup { # Initialize Logging Start-ToolkitLog "WinToolkitStarter" + + # Localization must be resolved before any path that emits translated + # messages. In particular, Initialize-UpdateServicesState can trigger an + # early Windows Update service restore (when a previous run left a + # RestoreFailed state) and that restore prints translation keys such as + # uiText.resettingWindowsUpdateServices. Resolving first prevents + # "[MISSING TRANSLATION]" warnings during that startup recovery. + $null = Resolve-SourceTextLanguage -RequestedLanguage $Language + Initialize-UpdateServicesState if ($PSVersionTable.PSVersion.Major -lt 7) { @@ -39,10 +48,6 @@ function Invoke-WinToolkitSetup { throw 'start-core.ps1 must be started by the elevated start.ps1 stub.' } - # Localization is prepared here, after logging exists and after the - # elevation check, so the GitHub API is never queried twice per run. - $null = Resolve-SourceTextLanguage -RequestedLanguage $Language - Show-Header -Title $script:AppConfig.Header.Title -Version $script:AppConfig.Header.Version foreach ($repair in @( @@ -172,7 +177,9 @@ function Invoke-WinToolkitSetup { finally { Invoke-StartUpdateServices try { Stop-Transcript -ErrorAction SilentlyContinue } catch { - Write-Warning "start-modules\90-Skeleton.Main.ps1, Invoke-WinToolkitSetup: $($_.Exception.Message)" + if ($_.Exception.Message -notmatch 'not currently transcribing') { + Write-Warning "start-modules\90-Skeleton.Main.ps1, Invoke-WinToolkitSetup: $($_.Exception.Message)" + } } $ErrorActionPreference = $previousErrorActionPreference }