Windows configuration
Enable Automatic Updates + Active Hours
Enables Windows automatic updates and sets active hours.
Replace generic placeholder values (tenant, domain, secrets) for your own environment before running. Read it first and test safely.
# Run as Administrator
# Sets Active Hours to 06:00-19:00, disables driver updates from Windows Update,
# and enables Automatic Updates (auto download + scheduled install).
$ErrorActionPreference = "Stop"
# --- Ensure Windows Update is enabled + running ---
Set-Service -Name wuauserv -StartupType Automatic
Start-Service -Name wuauserv
# Enable AU (auto download + scheduled install)
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" -Force | Out-Null
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" -Name AUOptions -Value 4
# Clear policy that disables AU (if present)
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name NoAutoUpdate -ErrorAction SilentlyContinue
# --- Active Hours: 6am (6) to 7pm (19) ---
$uxPath = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings"
New-Item -Path $uxPath -Force | Out-Null
Set-ItemProperty -Path $uxPath -Name ActiveHoursStart -Type DWord -Value 6
Set-ItemProperty -Path $uxPath -Name ActiveHoursEnd -Type DWord -Value 19
# Some Windows versions expose an enable flag - set if it exists
try {
New-ItemProperty -Path $uxPath -Name IsActiveHoursEnabled -PropertyType DWord -Value 1 -Force | Out-Null
} catch {}
# --- Disable drivers from Windows Update ---
# Primary supported policy key (Windows Update)
$polWU = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"
New-Item -Path $polWU -Force | Out-Null
New-ItemProperty -Path $polWU -Name ExcludeWUDriversInQualityUpdate -PropertyType DWord -Value 1 -Force | Out-Null
# Also disable "Device Installation Settings" style driver fetching (extra belt + braces)
$drvSearch = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching"
New-Item -Path $drvSearch -Force | Out-Null
New-ItemProperty -Path $drvSearch -Name SearchOrderConfig -PropertyType DWord -Value 0 -Force | Out-Null
Write-Host "Done."
Write-Host "Active Hours set to 06:00-19:00."
Write-Host "Driver updates via Windows Update disabled."
Write-Host "Note: If this PC is controlled by Group Policy/Intune, settings may revert on next sync."