Files
winutil/functions/public/Invoke-WPFUpdatesdefault.ps1
T

56 lines
2.3 KiB
PowerShell
Raw Normal View History

+3
2023-03-07 12:28:00 -08:00
function Invoke-WPFUpdatesdefault {
<#
2023-10-19 17:12:55 -05:00
.SYNOPSIS
Resets Windows Update settings to default
+3
2023-03-07 12:28:00 -08:00
#>
2026-01-08 21:04:36 +02:00
$ErrorActionPreference = 'SilentlyContinue'
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Removing Windows Update policy settings..." -ForegroundColor Green
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Recurse -Force
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Recurse -Force
Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" -Recurse -Force
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Recurse -Force
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Recurse -Force
Remove-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Recurse -Force
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Reenabling Windows Update Services..." -ForegroundColor Green
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Restored BITS to Manual"
Set-Service -Name BITS -StartupType Manual
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Restored wuauserv to Manual"
Set-Service -Name wuauserv -StartupType Manual
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Restored UsoSvc to Automatic"
Set-Service -Name UsoSvc -StartupType Automatic
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Restored WaaSMedicSvc to Manual"
Set-Service -Name WaaSMedicSvc -StartupType Manual
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Enabling update related scheduled tasks..." -ForegroundColor Green
2025-09-05 09:27:26 -05:00
2026-01-08 21:04:36 +02:00
$Tasks =
'\Microsoft\Windows\InstallService\*',
'\Microsoft\Windows\UpdateOrchestrator\*',
'\Microsoft\Windows\UpdateAssistant\*',
'\Microsoft\Windows\WaaSMedic\*',
'\Microsoft\Windows\WindowsUpdate\*',
2025-09-05 09:27:26 -05:00
'\Microsoft\WindowsUpdate\*'
2026-01-08 21:04:36 +02:00
foreach ($Task in $Tasks) {
Get-ScheduledTask -TaskPath $Task | Enable-ScheduledTask -ErrorAction SilentlyContinue
2025-09-05 09:27:26 -05:00
}
2026-01-08 21:04:36 +02:00
Write-Host "Windows Local Policies Reset to Default"
secedit /configure /cfg "$Env:SystemRoot\inf\defltbase.inf" /db defltbase.sdb
2024-10-29 16:58:14 -05:00
2026-01-08 21:04:36 +02:00
Write-Host "===================================================" -ForegroundColor Green
Write-Host "--- Windows Update Settings Reset to Default ---" -ForegroundColor Green
Write-Host "===================================================" -ForegroundColor Green
2025-09-16 19:04:11 +02:00
2026-01-08 21:04:36 +02:00
Write-Host "Note: You must restart your system in order for all changes to take effect." -ForegroundColor Yellow
}