I was recently tasked with the complete removal of Google Chrome from an environment. Google Chrome in question was installed via the default installer from Google, but also via a few custom repackaged installers, so I had multiple product IDs to consider.
Instead of manually looking for each product ID and use that with separate uninstallations, I figured to create some PowerShell code to do that for me automatically and on the fly.
This can be used to uninstall any application registered with the Windows installer, installed either as a .MSI or a select .EXE compiler.
The script can be found on my GitHub repository: PowerShell/Uninstall-Application.ps1 at master · imabdk/PowerShell (github.com)
The script accepts and requires the parameter -displayName. Use the name of the application, as it’s presented to you in Programs and Features.
The script queries registry for the installed application and looks for the attached UninstallString.
Package and Program
Use the script in a regular package with a program running the script:
- %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\Uninstall-Application.ps1 -displayName “Google Chrome”
NOTE: Notice that I call PowerShell from the sysnative library to force PowerShell into a 64-bit process. This is required, as a package in ConfigMgr runs as a 32-bit process. Otherwise the script cannot read the relevant parts of the registry.
For your convenience, a few snippet of the program. The script assumes the applications are installed for the local machine, hence it requires to run with administrative permissions.
- I have previously created a script, which is able to loop through applications installed in the user’s context as well. If that’s needed for your scenario, take a peek at this for inspiration: Uninstall all Zoom applications in a jiffy using Configuration Manager and Powershell – imab.dk
I added support to pass multiple values to the script parameter -displayName in order to uninstall multiple applications in one go 🙂