Skip to content

Instantly share code, notes, and snippets.

@asaf400
Last active June 13, 2022 16:23
Show Gist options
  • Save asaf400/584f803ddb7c383796a0aea6f3b38561 to your computer and use it in GitHub Desktop.
Save asaf400/584f803ddb7c383796a0aea6f3b38561 to your computer and use it in GitHub Desktop.
# Stop windows update service
Stop-Service -Name wuauserv;
# Remove 'SoftwarePolicies' WU key
Remove-Item `
-Path HKLM:\SoftwarePolicies\Microsoft\Windows\WindowsUpdate `
-Force `
-Recurse `
-ErrorAction SilentlyContinue;
# Remove 'SoftwarePolicies' WU key (This one is GPO Managed)
Remove-Item `
-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate `
-Force `
-Recurse `
-ErrorAction SilentlyContinue;
# Reset WU Agent data, by removing the 'SoftwareDistribution' directory, to be recreated with fresh default data, and rebuild the isntalled updates DB
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue "C:\Windows\SoftwareDistribution\"
# Start the WU server
Start-Service -Name wuauserv;
# Ask it to detect new updates, either by COM object, or CLI
wuauclt /detectnow
(New-Object -ComObject Microsoft.Update.AutoUpdate).DetectNow();
# I also had to check in the UI itself with command 'control update'
# This is usefull if your Windows installation is managed by IT department, which may block certain, or all updates
# but you still have Administrator level permissions on the workstation, which allows you to override them temporarily
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment