Finds an installed product by display name pattern across both uninstall registry roots and removes it silently, using the MSI product code where there is one and the quiet uninstall string otherwise. If the pattern matches more than one product it lists them and refuses to act, which is the behaviour you want from a removal script running unattended on a hundred machines.
powershell
# Uninstall Software by Display Name
# Single use case: silently remove one MSI-installed application
#-----------------------------------------------------------------
function Write-Log {
param($Message)
Write-Host "<WRITE-LOG = `"*$Message*`">"
}
# --- Parameters (replace via ServerEngine API parameters if needed) ---
$DisplayName = "7-Zip*" # wildcards allowed, matched against installed display names
$roots = @(
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*",
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
)
$apps = Get-ItemProperty $roots -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -like $DisplayName }
if (-not $apps) {
Write-Log "No installed software matches '$DisplayName' - nothing to do."
return
}
if (@($apps).Count -gt 1) {
Write-Log "Multiple matches for '$DisplayName':"
foreach ($a in $apps) { Write-Log " - $($a.DisplayName) $($a.DisplayVersion)" }
Write-Log "Refusing to uninstall more than one product - make the pattern more specific."
return
}
$app = $apps | Select-Object -First 1
Write-Log "Uninstalling: $($app.DisplayName) $($app.DisplayVersion)..."
if ($app.PSChildName -match "^\{[0-9A-F-]+\}$") {
# MSI product code -> silent msiexec
$proc = Start-Process msiexec.exe -ArgumentList "/x $($app.PSChildName) /qn /norestart" -Wait -PassThru
if ($proc.ExitCode -in @(0, 3010)) {
Write-Log "Uninstalled successfully (exit: $($proc.ExitCode))$(if ($proc.ExitCode -eq 3010) { ' - reboot required' })."
} else {
Write-Log "WARNING: msiexec exited with code $($proc.ExitCode)."
}
} elseif ($app.QuietUninstallString) {
Write-Log "Running quiet uninstall string..."
cmd /c $app.QuietUninstallString
Write-Log "Quiet uninstall command finished."
} else {
Write-Log "No silent uninstall available. UninstallString: $($app.UninstallString)"
Write-Log "Manual/interactive uninstall required - nothing was changed."
}Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Software Deployment
Install a Windows Feature with PowerShell
2026-08-17Install the RSAT Active Directory PowerShell Module
2026-08-17Silently Install PowerShell 7 Alongside 5.1
2026-08-17Install the SNMP Service with PowerShell
2026-08-17Install Windows Updates with PSWindowsUpdate
2026-08-17Automating Software Deployment with PowerShell
2025-01-04Ready when you are.
Try ServerEngine free for 7 days.