Skip to content

Instantly share code, notes, and snippets.

@gregmac
Created April 19, 2017 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregmac/86653b3697224e576600103437b46434 to your computer and use it in GitHub Desktop.
Save gregmac/86653b3697224e576600103437b46434 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