Uninstall security update for Windows 7 or 8 (PowerShell)

Introduction

This script demo shows how to uninstall security update for Windows 7 or 8.
Related scripts

Scenarios

It is not convenience to uninstall many updates manually. If it is a domain environment, there would be many clients with many updates. A script can achieved this quickly.

Script

This script contains one advanced function: Uninstall-OSCHotfix. You can use this script in the following ways:
Method 1:
  1. Download the script and open the script file together with Notepad or any other     script editor.
  2. Scroll down to the end of the script file, and then add     the example command which you want to run.
  3. Save the file then run the script in PowerShell.
Method 2:
  1. Rename scriptname.ps1 to scriptname.psm1 (PowerShell Module file)
  2. Run the following Import-Module cmdlet to import this module file.
            Import-Module filepath\scriptname.psm1
Here are some code snippets for your references. To get the complete script sample, please click the download button at the beginning of this page.
PowerShell
Edit|Remove
Foreach($HotfixID in $HotFixIDs) 
{ 
    $intNum =  1 
    Write-Progress -Activity "Uninstalling hotfix...." ` 
    -Status "$intNum of $IDsNum hotfixs" -PercentComplete $($intNum/$IDsNum*100) 
    $UninstallResult = UninstallHotFix $HotfixID $ComputerName  $Credential 
    $obj  = New-Object PSObject -Property @{ 
                                        HotFixID = $HotfixID; 
                                        Status = $UninstallResult 
                                        } 
    $result = $result + $obj 
    $intNum ++  
}

Examples

Example 1: Uninstall the specified hotfix in local computer.
Command: Uninstall-OSCHotfix -HotFixID KB2830290.
Screenshot:
 
 
Example 2: uninstall the specified hotfixs by using a text file.
Command: Uninstall-OSCHotfix -ListPath "C:\HotId.txt"
Screenshot:
 
Example 3: Uninstall the specified hotfix from other computer.
Command: Uninstall-OSCHotfix -HotFixID KB28000333 -ComputerName WIN-D23LGM8R8E5  -Credential (Get-Credential administrator)
Screenshot:
 
Note  This script can only uninstall Windows update and security update. 
 

Prerequisite

Windows 7 or 8