Uninstalls Windows applications installed at the HKLM registry level, regardless if they're .msi or .exe.
Requires an administration account to run this code in a powershell terminal; however a seperate .bat file can be created to execute the following code without a Powershell terminal:
powershell.exe -ExecutionPolicy UnRestricted -File %~dp0file-name.ps1
pauseNote: Ensure both .bat & .ps1 files reside in the same file directory or folder.
Script can be used in a Endpoint Configuration Manager to batch uninstall legacy or unwanted applications in a large enterprise environment that manages many computers or if a domain-joined user needs to remove a locally installed application on their computer.
Script performs the following at the Windows registry's (HKLM) Local Machine level:
- Tests if an application is installed, outputting the uninstall string and its location through the
-Searchswitch. - Will uninstall multiple versions of the same application, even if an application's
AppDatais found on different user profiles through the-Credentialswitch. - Will re-read the machine's registry to ensure there are no false positives with an application's removal.
- If a
.msi's uninstall switch is set to/i, the script will replace with the appropriate/xswitch.
Please make use of the "helper" code built-in to the script to learn more about syntax and view examples.
- Use the following command:
Get-Help C:\file-dir\file-name.ps1 -full