PowerShell: How to Find and Uninstall an MS Office Update

I was hunting for a clean way to remove MSOffice security update on a large number of workstations. I found some inconvenient solutions, but nothing was clean or general like using PowerShell and get-wmiobject using Win32_QuickFixEngineering and the .Uninstall method for the resulting object.

[Win32_QuickFixEngineering seems to apply only to Windows patches. See: http://social.technet.microsoft.com/Forums/en/winserverpowershell/thread/93cc0731-5a99-4698-b1d4-8476b3140aa3 ]

Question 1: Is there no way to use get-wmiobject to find MSOffice updates? There are so many classes and namespaces, I should be surprised.

This special Office update (KB978382) can be found in the registry here (for Office Ultimate):

HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{91120000-002E-0000-0000-0000000FF1CE}_ULTIMATER_{6DE3DABF-0203-426B-B330-7287D1003E86}

which kindly displays the delete command:

msiexec /package {91120000-002E-0000-0000-0000000FF1CE} /uninstall {6DE3DABF-0203-426B-B330-7287D1003E86}

and the latest GUID seems consistent between different versions of Office.

I also found the update as follows:
$wu = new-object -com "Microsoft.Update.Searcher"
$wu.QueryHistory(0,$wu.GetTotalHistoryCount()) | where {$_.Title -match "KB978382"}

I like this search because it does not require any registry search, but:

Question 2: If I found it this way, what can I do with the information I found to facilitate removal?

thanks

+4
source share
1 answer

By deploying the second approach (using Microsoft.Update.Searcher), this solution should allow you to search for the update by type and then remove it:

 $TitlePattern = 'KB978382' $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 $TitlePattern } | 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: http://technet.microsoft.com/en-us/library/cc720442(WS.10).aspx } } 
+4
source

Source: https://habr.com/ru/post/1308720/


All Articles