File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- 0.5.0
1+ 0.5.1
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ param(
2020
2121$mock = $false
2222
23+ function ExitWithCode ($exitCode ) {
24+ $host.SetShouldExit ($exitCode )
25+ Exit
26+ }
27+
2328Set-StrictMode - Version Latest
2429
2530$ErrorActionPreference = ' Stop'
2833 Write-Output " ERROR: $_ "
2934 Write-Output (($_.ScriptStackTrace -split ' \r?\n' ) -replace ' ^(.*)$' , ' ERROR: $1' )
3035 Write-Output (($_.Exception.ToString () -split ' \r?\n' ) -replace ' ^(.*)$' , ' ERROR EXCEPTION: $1' )
31- Exit 1
36+ ExitWithCode 1
3237}
3338
3439if ($mock ) {
@@ -41,10 +46,10 @@ if ($mock) {
4146 Write-Output " Synthetic reboot countdown counter is at $count "
4247 Set-Content $mockWindowsUpdatePath (-- $count )
4348 Write-Output ' Rebooting...'
44- Exit 101
49+ ExitWithCode 101
4550 }
4651 Write-Output ' No Windows updates found'
47- Exit 0
52+ ExitWithCode 0
4853}
4954
5055Add-Type @'
@@ -103,7 +108,7 @@ function ExitWhenRebootRequired($rebootRequired = $false) {
103108 Write-Output ' Pending Reboot detected. Waiting for the Windows Modules Installer to exit...'
104109 Wait-Condition {(Get-Process - ErrorAction SilentlyContinue TiWorker | Measure-Object ).Count -eq 0 }
105110 Write-Output ' Rebooting...'
106- Exit 101
111+ ExitWithCode 101
107112 }
108113}
109114
You can’t perform that action at this time.
0 commit comments