-
-
Save Arcath/9f89652244587a0ad902fd666fbe170c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################# | |
# | |
# 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