Uninstall a Windows HotFix

Uninstall a Windows HotFix

Removing a Windows hotfix

To uninstall a Windows hotfix, locate the KB hotfix number and run the below PowerShell command:

function Uninstall-Hotfix {
[cmdletbinding()]
param(
[string] $computername,
[string] $HotfixID
)            
 
$hotfixes = Get-WmiObject -ComputerName $computername -Class Win32_QuickFixEngineering | select hotfixid            
 
if($hotfixes -match $hotfixID) {
    $hotfixID = $HotfixID.Replace("KB","")
    Write-host "Found the hotfix KB" + $HotfixID
    Write-Host "Uninstalling the hotfix"
    $UninstallString = "cmd.exe /c wusa.exe /uninstall /KB:$hotfixID /quiet /norestart"
    ([WMICLASS]"\\$computername\ROOT\CIMV2:win32_process").Create($UninstallString) | out-null            
 
    while (@(Get-Process wusa -computername $computername -ErrorAction SilentlyContinue).Count -ne 0) {
        Start-Sleep 3
        Write-Host "Waiting for update removal to finish ..."
    }
write-host "Completed Uninstall of $hotfixID"
}
else {            
 
write-host "Hotfix($hotfixID) not found"
return
}            
 
}
 
 
 
Uninstall-HotFix -ComputerName PC1 -HotfixID KB3068708

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: