How to remove all installed Office Updates (via Windows Update) by PowerShell at once?

Recently I removed my Office 2016, and My PC remains so much Office update patchs.


enter image description here


From this question's answer, I learnt to use the Windows Update API commands to search the existing Office update patches. After spending a vast amount of time, I can't find any viable uninstalling command of Windows Update API. So how to perform the uninstalling step after I found all existing Office update patches?

4

2 Answers

Try a full removal of Office (Control Panel, Programs and Features). Office updates go away (for me, on all machines) when done this way.

The PowerShell script below is adapted from the post
PowerShell: How to find and uninstall a MS Office Update.

I have not tested it, so I suggest to at least create a System Restore point before trying it, and to debug it carefully while commenting out the command that does the actual uninstall: $Installer.Uninstall()and the command following it.

$Session = New-Object -ComObject Microsoft.Update.Session
$Collection = New-Object -ComObject Microsoft.Update.UpdateColl
$Installer = $Session.CreateUpdateInstaller()
$Searcher = $Session.CreateUpdateSearcher()
$Searcher.QueryHistory(0, $Searcher.GetTotalHistoryCount()) | Where-Object { $_.Title -match 'Update for Microsoft Office' } | ForEach-Object { Write-Verbose "Found update history entry $($_.Title)" $SearchResult = $Searcher.Search("UpdateID='$($_.UpdateIdentity.UpdateID)' and RevisionNumber=$($_.UpdateIdentity.RevisionNumber)") Write-Verbose "Found $($SearchResult.Updates.Count) update entries" if ($SearchResult.Updates.Count -gt 0) { $Installer.Updates = $SearchResult.Updates $Installer.Uninstall() $Installer | Select-Object -Property ResultCode, RebootRequired, Exception # result codes: (WS.10).aspx } }
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like