Skip to content

Instantly share code, notes, and snippets.

@Arcath
Last active December 25, 2017 06:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arcath/9f89652244587a0ad902fd666fbe170c to your computer and use it in GitHub Desktop.
Save Arcath/9f89652244587a0ad902fd666fbe170c to your computer and use it in GitHub Desktop.
#############################################################
#
# Office Update Remover
#
# By Adam Laycock (arcath.net)
# September 2017
#
#############################################################
Param(
[Parameter(Mandatory=$True,Position=1)][string]$kb
)
$officePID = $False
$updatePID = $False
Get-ChildItem HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall -rec -ea SilentlyContinue | foreach {
$currentKey = Get-ItemProperty -Path $_.PsPath
if($currentKey.DisplayName -like "*" + $kb + "*"){
$parts = $currentKey.PSChildName.Split("_")
$officePID = $parts[0]
$updatePID = $parts[2]
}
}
# If the patch was not in 64bit registry look in 32 bit
if($officePID -eq $False -and $updatePID -eq $False){
Get-ChildItem HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall -rec -ea SilentlyContinue | foreach {
$currentKey = Get-ItemProperty -Path $_.PsPath
if($currentKey.DisplayName -like "*" + $kb + "*"){
$parts = $currentKey.PSChildName.Split("_")
$officePID = $parts[0]
$updatePID = $parts[2]
}
}
}
if($officePID -ne $False -and $updatePID -ne $False){
$args = @(
"/package"
$officePID
"/uninstall"
$updatePID
"/qn"
"/quiet"
"/norestart"
)
Write-Host "msiexec" $args
Start-Process "msiexec.exe" -ArgumentList $args -Wait -NoNewWindow
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment