Last active
June 13, 2022 16:23
-
-
Save asaf400/584f803ddb7c383796a0aea6f3b38561 to your computer and use it in GitHub Desktop.
Based on 2 answers: https://trevorsullivan.net/2011/12/14/powershell-override-gpo-and-detect-windows-updates/ and https://superuser.com/questions/107155/windows-update-when-group-policy-forbids/479972
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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