Have created a script to uninstall only SSMS 18.10 and retain SSMS 19.3

I have created a script to uninstall only SSMS 18.10 and retain SSMS 19.3. I observe the registry keys are getting removed and folder in Program Files are getting removed . But the issue is after uninstall the entry in control panel still exist. Please suggest on this

Get the list of installed applications and filter by SSMS version

$app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Version -like “15.0.18390.0” }

$app1 = Get-WmiObject -Class Win32_Product | Where-Object { $.Name -like “isolated” -and $.Version -like “15.0.28307.421” }
$app2 = Get-WmiObject -Class Win32_Product | Where-Object { $.Name -like “Integration services” -and $.Version -like “15.0.2000.168” }
$app3 = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like “Microsoft SQL Server 2012 Native Client” }
$app_new = @($app,$app1,$app2,$app3)

$app_new

Check if the application is found

if ($app_new) {
# Uninstall the application
$app_new | ForEach-Object {
Write-Host “Uninstalling: $($.Name) - Version: $($.Version)”
$_.Uninstall()
}
}

Delete the SSMS 18.10 registry key

Remove-Item -Path “Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server Management Studio\18” -Recurse -Force

Remove-Item ‘C:\Program Files (x86)\Microsoft SQL Server Management Studio 18’ -Recurse -Force

Can you please suggest?

Well it looks like you’re manually removing the filesystem path and the registry key, but your uninstall command is probably not working correctly. I’m not familiar with those uninstall methods you’re using, you may need to post that on a SQL forum to ask about them.

@shruthi if I understand you correctly what’s you actually want to do is to uninstall older versions of ssms and retain the latest version that is currently installed on the machine?

@orbiton Yes your correct. Actually complete uninstall is happening but a entry in control panel still remains. After uninstall i verified manually by typing the SSMS in START menu ,there was no older version showing up . Also the below sub folder is empty after uninstall , but the folder entry remains so deleting it manually.

Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Microsoft SQL Server Management Studio\18” -Recurse -Force

Remove-Item ‘C:\Program Files (x86)\Microsoft SQL Server Management Studio 18’ -Recurse -Force

I really wish there was an option that would do this with the installer. If there is one, it would be great if HCL would include that say as “Action 2” and we could use that!