Last active
September 1, 2015 13:46
-
-
Save smorris93/85e5fe6d5041e7bd4c0d to your computer and use it in GitHub Desktop.
Powershell script that uninstalls every windows update on your current machine.
This file contains 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
# This script will uninstall every windows update on your machine (that it can) | |
# Don't run unless you really want all updates removed ... | |
# Restart PC when finished | |
$file = "./updateList.txt" | |
Function GetUpdateList | |
{ | |
if(Test-Path $file) { | |
Remove-Item $file | |
} | |
wmic qfe get "HotFixID" >> $file | |
(gc $file) | ? {$_.trim() -ne "" } | set-content $file | |
get-content $file | | |
select -Skip 1 | | |
set-content "$file-temp" | |
move "$file-temp" $file -Force | |
} | |
Function RemoveUpdates | |
{ | |
if(Test-Path $file) { | |
$updateIds = Get-Content -Path $file | |
$numOfIds = $updateIds.Count | |
$count = 1; | |
Foreach($updateId in $updateIds) { | |
$output = "Uninstalling Update $count of $numOfIds " | |
$output | |
$updateNum = $updateId.Replace("KB", "") | |
$updateNum = $updateNum.Replace(" ", "") | |
wusa.exe /kb:$updateNum /uninstall /quiet /norestart | Out-Null | |
$count++ | |
} | |
} | |
if(Test-Path $file) { | |
Remove-Item $file | |
} | |
Write-Host "Done ... Please restart your machine" | |
Write-Host "Press any key to continue ..." | |
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") | |
} | |
GetUpdateList | |
RemoveUpdates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment