-
-
Save darkmanlv/a7432c559ba6e99cce40642d3f9dad7a to your computer and use it in GitHub Desktop.
Uninstall all Microsoft SQL Server stuff
This file contains hidden or 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
| # 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