Add methods for managing auto restart feature

This commit is contained in:
Manuel Thalmann 2024-08-12 01:23:42 +02:00
parent b6a1f7323c
commit b447d37f62

View file

@ -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";
}
}