I’m attempting to Uninstall the new version Microsoft SQL Server Management Studio using the Start-ADTProcess command, followed by some clean-up tasks in the Post-Uninstall section.
The Removal of the application works as expected but the Post-Uninstall section is skipped and the Finalization action is run
I have added both -Nowait and -PassThru to the command line in an attempt to get the Post-Uninstall section to run but neither caused the Post-Uninstall actions to run
If I run the process with the Start-ADTProcess command rem’ed out the script runs the Post-Uninstall section as expected
The Start-ADTProcess Command is:
Start-ADTProcess -FilePath “$envProgramFilesX86\Microsoft Visual Studio\Installer\setup.exe” -ArguentList ‘uninstall --installPath “C:\Program Files\Microsoft SQL Server Management Studio 21\Release” --quiet’
Hoping someone knows how to stop this process closing PSAppDeployToolkit
I’m hoping it’s a typo in what you have written here, but you might want to check your spelling of ArgumentList
IMHO it should read:
Start-ADTProcess -FilePath "$envProgramFilesX86\Microsoft Visual Studio\Installer\setup.exe" -ArgumentList 'uninstall --installPath "C:\Program Files\Microsoft SQL Server Management Studio 21\Release" --quiet'
N.B. I also changed your ANSI single and double quotes i.e. ‘, ’, “ & ” for ASCII single and double quotes i.e.' and " as the ANSI version will likely cause PowerShell to baulk
OK so what commands do you have in your Post-Uninstall section?
If you use the Pre-formatted text button on the tool bar here </> and replace the ‘type or paste your code here’ text between the two rows of 3 escape chars with your code we can see what your code looks like and assist further.
Another tip, if you surround your $envProgramFilesX86 variable with $() it usually helps with expanded paths with spaces within them, e.g.
Start-ADTProcess -FilePath "$($envProgramFilesX86)\Microsoft Visual Studio\Installer\setup.exe" -ArgumentList 'uninstall --installPath "C:\Program Files\Microsoft SQL Server Management Studio 21\Release" --quiet'
and just reviewing this… why is your command line calling the Installer from a Microsoft Visual Studio folder structure for Microsoft SQL Server Management Studio?
The latest SSMS is very different from previous versions and is now integrated into Visual Studio, hence the need to use the Visual Studio Installer to remove the the application. The installer is no longer SSMS_Setup_ENU.exe, for v21 its vs_SSMS.exe, which includes the Visual Studio Installer.
The Post-Uninstall actions are to remove the Visual Studio Installer as the only product we are currently using that installs it is SSMS and remove and empty SSMS Folder that is left behind when the application removal finishes
# Uninstall SSMS
Start-ADTProcess -FilePath "$envProgramFilesx86\Microsoft Visual Studio\Installer\setup.exe" -ArgumentList 'uninstall --installPath "C:\Program Files\Microsoft SQL Server Management Studio 21\Release" --quiet'
##================================================
## MARK: Post-Uninstallation
##================================================
$adtSession.InstallPhase = "Post-$($adtSession.DeploymentType)"
## <Perform Post-Uninstallation tasks here>
# Remove Additional Components
# Microsoft Visual Studio Installer
Uninstall-ADTApplication -Name "Microsoft Visual Studio Installer" -ApplicationType "EXE" -AdditionalArgumentList "--quiet"
# vs_CoreEditorFonts
Uninstall-ADTApplication -Name "vs_CoreEditorFonts" -ApplicationType "MSI"
# Remove Empty Folder left behind when SSMS is uninstalled
Remove-ADTFolder -Path "C:\Program Files\Microsoft SQL Server Management Studio 21"
When the Uninstall runs, this works as expected but the Post-Uninstall aren’t run. If I remove the Uninstall command from the script then the Post-Uninstall actions run as expected, log output below:
Uninstall Run, No Post-Uninstall Actions performed
Ah that makes sense now - Thanks (I’ve been holding off deploying SSMS v21 to our Data team, until our legacy SQL platform has been retired)
I can see what you are doing and why you need to do it this way - you are right it does appear to be something to do with the way the Start-ADTProcess exits.
Having trawled my memory, I think the fix for the Start-ADTProcess (and an explaination why) is in this reply to a related discussion:
It looks like you may need to include the argument -AllowRebootPassThru
If you find that doesn’t work, i’m just wondering, if you could try replacing your Start-ADTProcess command to uninstall SSMS and replace it with the equivalent Uninstall-ADTApplication (Syntax like you’ve used in the Post-Uninstallation section)? As this may be the alternative way to achieve the same result
Adding -AllowRebootPassThru didn’t work as it isn’t an option Start-ADTProcess supports and PSAppDeployToolkit errored with a A parameter cannot be found that matches name 'AllowRebootPassThru' but switching the Uninstall to Uninstall-ADTApplication worked.
Using the command Uninstall-ADTApplication -Name "SQL Server Management Studio 21" -ApplicationType "EXE" -AdditionalAgrumentList "--quiet" runs, what looks like, the exact same command I was originally using but this time when the application uninstall action was completed the Post-Uninstall actions ran as expected