26 February 2018

Uninstall MSI by GUID

This script function will uninstall an MSI installed application by specifying the GUID and the switches. I have included the ability for the script to query the registry for the name of the application to display for user output. The function also will exit the script if there was a failure.

NOTE: The script uses write-host for user output so that if it is manually executed, the admin will be able to easily see if it was successful by success being in yellow, not installed in green, and failure in red. Write-Host is the only option for being able to display in multiple colors and the ability to not start a new line when it displays "Uninstalling Java 8 u 161....." as it waits for the exit code of the uninstall to show one of the three outputs above in the designated colors. If you do not want to use write-host for this, you are welcome to rewrite the code, which is being openly shared.

Here is an example of the function running in the script provided below. This is not in color because it was executed within PowerShell Studio. This is in a script format so you can easily test this out before using the function in another script.


You can download the script from my GitHub site

0 comments:

Post a Comment