Skip to content

Instantly share code, notes, and snippets.

@darkmanlv
Forked from gregmac/uninstall-mssql.ps1
Created May 6, 2026 10:01
Show Gist options
  • Select an option

  • Save darkmanlv/a7432c559ba6e99cce40642d3f9dad7a to your computer and use it in GitHub Desktop.

Select an option

Save darkmanlv/a7432c559ba6e99cce40642d3f9dad7a to your computer and use it in GitHub Desktop.
Uninstall all Microsoft SQL Server stuff
# Powershell script to uninstall all Microsoft SQL Server stuff.
# There's so many entries it's a pain to uninstall everything manually. Run via PowerShell (or PowerShell ISE) as Admin.
# Warning: this still prompts for confirmation on a bunch of items.
$uninstall32 = gci "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SQL Server" } | select DisplayName,UninstallString
$uninstall64 = gci "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | foreach { gp $_.PSPath } | ? { $_ -match "SQL Server" } | select DisplayName,UninstallString
$uninstall = $uninstall32 + $uninstall64 | where {$_.UninstallString -match "MsiExec"} | Sort DisplayName
$uninstall| format-table
$uninstall | foreach {
$u = (($_.UninstallString -replace "/I", "/X") -replace "msiexec.exe","") + " /qb"
Write-Host "..."
Write-Host "Uninstalling $($_.DisplayName) with $u"
start-process "msiexec.exe" -arg $u -Wait
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment