Add ForceReboot option to force reboot after Windows Updates regardless of pending reboot state

This commit is contained in:
Patrick Asmus
2026-07-14 14:39:42 +02:00
parent c236b08311
commit e7d116b099
3 changed files with 17 additions and 5 deletions

View File

@@ -9,9 +9,9 @@ Author: Patrick Asmus
Web: https://www.cleveradmin.de
Repository: https://git.techniverse.net/scriptos/windows-updater.git
License: MIT
Version: 2.8.0
Date: 07.07.2026
Modifications: Add -DefenderOnly, -DryRun, -ConfigFile parameters and UpdateType config option
Version: 2.9.0
Date: 14.07.2026
Modifications: Add ForceReboot option to force reboot after Windows Updates regardless of pending reboot state
#####################################################
#>
@@ -1344,8 +1344,15 @@ function Start-WindowsUpdater {
# --- Reboot Handling (skip in DefenderOnly mode) ---
if (-not $script:DefenderOnlyMode) {
$script:RebootPending = Test-PendingReboot
if ($script:RebootPending) {
Write-Log "System reboot is pending"
$forceReboot = Get-ConfigValue -Config $script:Config -Section "Reboot" -Key "ForceReboot" -Default $false -Type bool
if ($script:RebootPending -or $forceReboot) {
if ($forceReboot -and -not $script:RebootPending) {
Write-Log "ForceReboot is enabled, rebooting even though no reboot is pending"
}
else {
Write-Log "System reboot is pending"
}
$rebootHandled = Invoke-ScheduledReboot
if (-not $rebootHandled) {
Write-Log "Auto-reboot is disabled, manual reboot required" -Level WARN