Skip to content

Instantly share code, notes, and snippets.

@TheRemote
Last active April 26, 2026 18:17
Show Gist options
  • Select an option

  • Save TheRemote/84f994a45a251ed6f0a0fbce707bfd5c to your computer and use it in GitHub Desktop.

Select an option

Save TheRemote/84f994a45a251ed6f0a0fbce707bfd5c to your computer and use it in GitHub Desktop.
Fix-WindowsUpdate.ps1 - Reset Microsoft Windows Update
# For my blog article at https://jamesachambers.com/the-nuclear-option-a-powershell-script-to-reset-windows-update-completely/
# Fix-WindowsUpdate.ps1 — Reset Windows Update to a clean state
"Setting Windows Update settings..."
if (-Not (Test-Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU"
}
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name 'AUOptions' -Value 4 -Verbose -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name 'AutomaticMaintenanceEnabled' -Value 1 -Verbose -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name 'NoAutoUpdate' -Value 0 -Verbose -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name 'UseWUServer' -Value 0 -Verbose -ErrorAction SilentlyContinue
Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name 'AllowMUUpdateService' -Value 1 -Verbose -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "SetDisableUXWUAccess" -Verbose -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -Verbose -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferFeatureUpdate" -Verbose -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate" -Name "DeferQualityUpdate" -Verbose -ErrorAction SilentlyContinue
Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" -Name AccountDomainSid, PingID, SusClientId, SusClientIDValidation -ErrorAction SilentlyContinue
"Stopping Windows Update Services..."
Stop-Service -Name BITS -Force
Stop-Service -Name wuauserv -Force
Stop-Service -Name appidsvc -Force
Stop-Service -Name cryptsvc -Force
"Renaming the Software Distribution Folder..."
Remove-Item $env:systemroot\SoftwareDistribution.bak -Recurse -Force -ErrorAction SilentlyContinue
Rename-Item $env:systemroot\SoftwareDistribution SoftwareDistribution.bak -ErrorAction Continue
Remove-Item $env:systemroot\SoftwareDistribution.bak -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $env:systemroot\SoftwareDistribution -Recurse -Force -ErrorAction Continue
"Renaming the Catroot2 Folder..."
Remove-Item $env:systemroot\System32\catroot2.bak -Recurse -Force -ErrorAction SilentlyContinue
Rename-Item $env:systemroot\System32\Catroot2 catroot2.bak -ErrorAction Continue
Remove-Item $env:systemroot\System32\catroot2.bak -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item $env:systemroot\System32\catroot2 -Recurse -Force -ErrorAction Continue
"Reset certs..."
certutil -urlcache * delete
"Remove QMGR Data file..."
Remove-Item "$Env:AllUsersProfile\Application Data\Microsoft\Network\Downloader\qmgr*.dat" -ErrorAction SilentlyContinue
"Removing old Windows Update log..."
Remove-Item $env:systemroot\WindowsUpdate.log -ErrorAction SilentlyContinue
Set-Location $env:systemroot\system32
"Registering some DLLs..."
regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll
regsvr32.exe /s bitsperf.dll
"Resetting the Winsock..."
netsh winsock reset
netsh winhttp reset proxy
"Delete all BITS jobs..."
Get-BitsTransfer | Remove-BitsTransfer
"Starting Windows Update Services..."
Start-Service -Name BITS
Start-Service -Name wuauserv
Start-Service -Name appidsvc
Start-Service -Name cryptsvc
"Forcing discovery..."
wuauclt /resetauthorization /detectnow
USOClient.exe RefreshSettings
USOClient.exe StartScan
USOClient.exe StartInteractiveScan
"Process complete. Please reboot your computer."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment