A script to remove a specific installed patch in a domain.

I have approved a patch with some conflict ions with Office 2010 modules, the KB number is 3097877. I have researched online and combined a script like below. However, when I ran this script with a complied computer name list file, it gave me errors like below. Please help me modify this script to make it possible.

Thanks.

Script
function Uninstall-Hotfix {
[cmdletbinding()]
param(
$computername = $env: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 the uninstallation of $hotfixID"
}
else {            

write-host "Given hotfix($hotfixID) not found"
return
}            

}



$myComputers = Get-Content "c:\PowerShell Scripts\computers_needremove.txt"
foreach ($computer in $myComputers) {
 Uninstall-HotFix -ComputerName $computer -HotfixID KB3097877
}

Open in new window



Error i got when running the above script:


function Uninstall-Hotfix {
[cmdletbinding()]
param(
$computername = $env: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 the uninstallation of $hotfixID"
}
else {            

write-host "Given hotfix($hotfixID) not found"
return
}            

}



$myComputers = Get-Content "c:\PowerShell Scripts\computers_needremove.txt"
foreach ($computer in $myComputers) {
 Uninstall-HotFix -ComputerName $computer -HotfixID KB3097877
}
Jason YuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FOXActive Directory/Exchange EngineerCommented:
The line Uninstall-Hotfix should read

Uninstall-HotFix -ComputerName $myComputers -HotfixID kb3097877
0
FOXActive Directory/Exchange EngineerCommented:
As a matter of fact Microsoft fixed this patch, you will just have to pull it down again and reinstall it.  It has fixed the previous issues everyone was having.

http://www.infoworld.com/article/3004441/microsoft-windows/microsoft-surreptitiously-reissues-botched-patch-kb-3097877-for-windows-7.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason YuAuthor Commented:
We use WSUS server to deploy windows patches, how could I redownload the same patch on WSUS server?

I couldn't find a place to delete the old version, please help.
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

FOXActive Directory/Exchange EngineerCommented:
in wsus do a download of new updates and it will pull down the fixed kb that was corrupted last week.  It is using the same kbnumber How often does your wsus server pull down updates?  It may have pulled it down already.
0
Jason YuAuthor Commented:
I checked in "OPTIONS || SYNCHRONIZATION SCHEDULE" and found out that we have schedule to synchronize daily at 10:20 PM.
0
Jason YuAuthor Commented:
So, after I download and approve the new revised patch, it will replace the old installed patch on all workstations?

Please advise, thanks.
0
FOXActive Directory/Exchange EngineerCommented:
Yes it will
0
Jason YuAuthor Commented:
Thanks, I will do it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.