Update uninstall-MS-Visual-C++-2010.ps1

This commit is contained in:
Ivo Oskamp 2025-08-29 09:47:16 +02:00
parent 15cd2b8c3f
commit 532f471e90

View File

@ -1,5 +1,13 @@
# This script is designed for use in Datto RMM (CentraStage). # This script is designed for use in Datto RMM (CentraStage).
# Purpose: Uninstall all "Microsoft Visual C++ 2010 ... Redistributable" (x86/x64), version independent. # Purpose: Uninstall all "Microsoft Visual C++ 2010 ... Redistributable" (x86/x64), version independent.
#
# Example run / expected output:
# Uninstall Microsoft Visual C++ 2010
# Found: Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219, Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219
# Uninstall (MSI) Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219 -> msiexec /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7} /quiet /norestart
# Uninstall (MSI) Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 -> msiexec /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5} /quiet /norestart
# Completed: all target items successfully removed (or not present).
#
# Exit codes: # Exit codes:
# 0 = OK (nothing found or everything removed successfully) # 0 = OK (nothing found or everything removed successfully)
# 1 = Failures occurred # 1 = Failures occurred
@ -78,3 +86,30 @@ $uninstallKeys = @(
$targets = foreach ($key in $uninstallKeys) { $targets = foreach ($key in $uninstallKeys) {
Get-ItemProperty -Path $key -ErrorAction SilentlyContinue | Get-ItemProperty -Path $key -ErrorAction SilentlyContinue |
Where-Object {
$_.DisplayName -and ($_.DisplayName -like "Microsoft Visual C++ 2010*Redistributable*")
}
}
if (-not $targets) {
Write-Output "No Microsoft Visual C++ 2010 Redistributables found. Nothing to do."
exit 0
}
$foundList = ($targets.DisplayName | Sort-Object -Unique) -join ", "
Write-Output ("Found: " + $foundList)
# Uninstall each item
foreach ($app in $targets) {
$name = $app.DisplayName
$cmd = if ($app.QuietUninstallString) { $app.QuietUninstallString } else { $app.UninstallString }
Invoke-Uninstall -CmdLine $cmd -AppName $name
}
if ($fails -gt 0) {
Write-Output ("Completed with errors: " + $fails + " item(s) failed to uninstall.")
exit 1
} else {
Write-Output "Completed: all target items successfully removed (or not present)."
exit 0
}