All checks were successful
release / build-and-release (push) Successful in 24s
xetup.exe now acts as an orchestrator across system reboots: - PS scripts exit 9 to signal "reboot needed, re-run me" (WU) or "done but reboot needed to finalize" (Dell BIOS) - On exit 9: xetup saves state.json, ensures adminx9 account, copies itself to stable path, enables autologon, registers X9-Resume scheduled task (AtLogOn adminx9, RunLevel Highest) - On resume: loads pending steps from state, continues seamlessly with "Pokracuji po restartu..." label in the run window - On completion: disables autologon, removes X9-Resume task, deletes state file, shows summary with accumulated results across all reboot rounds New packages: internal/state, internal/prereboot Script 12: simplified to exit 0 (done) or exit 9 (reboot needed) Script 11: exit 9 when DCU exit code 1 (BIOS staged, reboot needed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
85 lines
3.3 KiB
PowerShell
85 lines
3.3 KiB
PowerShell
<#
|
|
.SYNOPSIS
|
|
Installs all available Windows Updates via PSWindowsUpdate module.
|
|
|
|
.DESCRIPTION
|
|
Installs all currently available updates without rebooting.
|
|
Exits with code 9 when updates were installed (reboot required for
|
|
further rounds) or code 0 when the system is already fully up to date.
|
|
|
|
The xetup.exe state machine handles the reboot cycle:
|
|
- exit 9 -> xetup saves state, sets autologon + X9-Resume task, reboots
|
|
- on each subsequent logon X9-Resume launches xetup --resume
|
|
- xetup re-runs this step until it exits 0 (no more updates)
|
|
- then disables autologon, removes X9-Resume, shows the summary screen
|
|
|
|
.ITEMS
|
|
nainstalovat-pswindowsupdate-modul: Installs NuGet provider and PSWindowsUpdate module from PSGallery.
|
|
spustit-kolo-windows-update: One update pass without reboot. Exits 9 when updates were applied (more rounds needed). Exits 0 when system is fully up to date.
|
|
#>
|
|
param(
|
|
[object]$Config,
|
|
[string]$LogFile
|
|
)
|
|
|
|
$ErrorActionPreference = "Continue"
|
|
|
|
function Write-Log {
|
|
param([string]$Message, [string]$Level = "INFO")
|
|
$line = "[$(Get-Date -Format 'HH:mm:ss')] [$Level] $Message"
|
|
$null = New-Item -ItemType Directory -Force -Path (Split-Path $LogFile -Parent) -ErrorAction SilentlyContinue
|
|
Add-Content -Path $LogFile -Value $line -Encoding UTF8
|
|
Write-Output $line
|
|
}
|
|
|
|
Write-Log "=== Step 12 - Windows Update ===" -Level STEP
|
|
|
|
# -----------------------------------------------------------------------
|
|
# 1. NuGet provider + PSWindowsUpdate module
|
|
# -----------------------------------------------------------------------
|
|
Write-Log "Setting up PSWindowsUpdate module..." -Level INFO
|
|
try {
|
|
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope AllUsers | Out-Null
|
|
$existing = Get-Module -ListAvailable -Name PSWindowsUpdate | Select-Object -First 1
|
|
if ($existing) {
|
|
Write-Log " PSWindowsUpdate $($existing.Version) already installed" -Level INFO
|
|
} else {
|
|
Install-Module -Name PSWindowsUpdate -Force -Scope AllUsers -AllowClobber | Out-Null
|
|
Write-Log " PSWindowsUpdate installed" -Level OK
|
|
}
|
|
Import-Module PSWindowsUpdate -Force
|
|
} catch {
|
|
Write-Log " Module setup failed: $_" -Level ERROR
|
|
exit 1
|
|
}
|
|
|
|
# -----------------------------------------------------------------------
|
|
# 2. Check and install available updates
|
|
# -----------------------------------------------------------------------
|
|
Write-Log "Checking for available Windows Updates..." -Level INFO
|
|
try {
|
|
$available = Get-WindowsUpdate -AcceptAll -IgnoreReboot -ErrorAction Stop
|
|
} catch {
|
|
Write-Log " Failed to check for updates: $_" -Level ERROR
|
|
exit 1
|
|
}
|
|
|
|
if (-not $available -or $available.Count -eq 0) {
|
|
Write-Log " System is fully up to date" -Level OK
|
|
Write-Log "Step 12 complete" -Level OK
|
|
exit 0
|
|
}
|
|
|
|
Write-Log " Found $($available.Count) update(s) - installing..." -Level INFO
|
|
try {
|
|
$result = Install-WindowsUpdate -AcceptAll -IgnoreReboot -Verbose 2>&1
|
|
$result | Where-Object { "$_" -match '\S' } | ForEach-Object { Write-Log " $_" -Level INFO }
|
|
Write-Log " Update pass complete - reboot required for next round" -Level OK
|
|
} catch {
|
|
Write-Log " Update install failed: $_" -Level ERROR
|
|
exit 1
|
|
}
|
|
|
|
# Signal xetup that a reboot is needed before running this step again
|
|
Write-Log "Step 12 - reboot required (exit 9)" -Level OK
|
|
exit 9
|