diff --git a/scripts/Windows/Scripts/Registry.ps1 b/scripts/Windows/Scripts/Registry.ps1 index 2ce9b9e6..2d63e659 100644 --- a/scripts/Windows/Scripts/Registry.ps1 +++ b/scripts/Windows/Scripts/Registry.ps1 @@ -1,6 +1,8 @@ using namespace Microsoft.Win32; $null = New-Module { + $wuPolicyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"; + function Edit-DefaultUserKey { param( [scriptblock] $Action @@ -53,4 +55,22 @@ $null = New-Module { function Disable-BootMessage { Set-BootMessage; } + + <# + .SYNOPSIS + Disables automatic reboots by Windows Update. + #> + function Disable-WindowsUpdateAutoRestart { + Set-ItemProperty "$wuPolicyPath\AU" ` + -Name NoAutoRebootWithLoggedOnUsers ` + -Value $Value; + } + + <# + .SYNOPSIS + Resets the automatic reboot state. + #> + function Reset-WindowsUpdateAutoRestart { + Remove-Item -Recurse "$wuPolicyPath"; + } }