Thursday 22 December 2022

PowerShell: Universal Uninstaller (Script to fetch the uninstall string of all the installed apps)

There are multiple ways to get the installed apps removed from the device. This script particularly helps to find the uninstall string of all the installed apps from the registry, which include MSI, and EXE. The administrator can run this and choose the specific application to uninstall it.

Script:

$64apps=Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, UninstallString, InstallLocation

$32apps=Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate, UninstallString, InstallLocation

$allinstalledapps = $64apps + $32apps

$RUninst=$allinstalledapps| Out-GridView -Title "Select Application to Uninstall" –PassThru | Select-Object -ExpandProperty UninstallString

if($RUninst)

{

foreach ($Run in $RUninst)

{

&cmd /c $Run

}

}

else

{

Get-Package -ProviderName msi -AllVersions| Out-GridView -Title "Select Application to Uninstall" –PassThru | Uninstall-Package -Confirm

}


Steps To Do:
1. Copy the code and save the script as XXX.PS1

2. Set the execution policy to run the script.

3. Execute the script as administrator and it will display the details in Grid view.

4. Select an app that has the uninstall string and click "ok" to proceed with uninstall.

5. Proceed with the next steps to uninstall the selected app.


Note: If there is no Uninstall String visible for an app, upon selecting that app will show you another grid view, where you can select and uninstall the app using the default PowerShell "Get-package" method.