Remove-Application
Description
Removes an application or a list of comma-separated applications either by normal means or forcefully.
Requirements
PowerShell V.5
Usage
- Search for the object
- Check the application log for an error and exit if not found.
- If there are more than one result for the search term $Name, notify the user that there are multiple results and to refine their search.
 
- Determine the type of uninstallation object that $Namereferences (AppX, MSI, EXE).- AppX
- Remove the AppX object.
- Check for the item after removal to confirm.
- Exit.
 
- MSI
- Attempt to remove the MSI package using the uninstall string.
- Log the success or failure of the uninstallation.
 
- EXE
- Check if a custom switch is provided. If so, attempt to uninstall using the provided switch.
- If the custom switch fails or is not provided, attempt to uninstall using the QuietUninstallStringif available.
- If the QuietUninstallStringfails or is not available, attempt to uninstall using targeted silent switches.
- If targeted silent switches fail, attempt to uninstall using the UninstallStringwithout modifications.
- Log the success or failure of each uninstallation attempt.
 
 
- AppX
- Check if the application is still installed.
- If the application is not installed, log the successful removal and exit.
- If the application is still installed and the -Forceparameter is specified, proceed with forced removal.
 
- Forced Removal (if -Forceparameter is specified)- Terminate any processes related to the application.
- Remove the application's files and directories.
- Remove the application's shortcuts.
- Remove the application's registry keys.
- Log the success or failure of the forced removal.
 
.\Remove-Application.ps1 -Name 'Google Chrome', 'Teams Machine-Wide Installer', 'ConnectWise Manage Client 64-bit'
Will attempt to remove Google Chrome, Teams Machine-Wide Installer, and 'ConnectWise Manage Client 64-bit' applications normally.
.\Remove-Application.ps1 -Name 'Google Chrome', 'Teams Machine-Wide Installer', 'ConnectWise Manage Client 64-bit' -SystemComponentOverride
Will attempt to remove Google Chrome, Teams Machine-Wide Installer, and 'ConnectWise Manage Client 64-bit' applications normally. If the application is registered as a system component, it will continue to remove the application.
.\Remove-Application.ps1 -Name 'Google Chrome'
Will attempt to remove Google Chrome normally.
.\Remove-Application.ps1 -Name 'Google Chrome' -Force
Will attempt to remove Google Chrome normally, but if it fails, it will attempt a forceful removal of the application.
.\Remove-Application.ps1 -Name 'Google Chrome' -Force -SystemComponentOverride
Will attempt to remove Google Chrome normally, but if it fails, it will attempt a forceful removal of the application. If the application is registered as a system component, it will continue to remove the application.
.\Remove-Application.ps1 -Name 'Microsoft.BingWeather'
Will remove Bing Weather.
.\Remove-Application.ps1 -Name 'Google Chrome' -Switch '--uninstall --multi-install --chrome --system-level --force-uninstall'
Will attempt to remove Google Chrome using the provided custom switch.
Parameters
| Parameter | Alias | Required | Default | Type | Description | 
|---|---|---|---|---|---|
| Name | True | String[] | The name or the comma-separated list of the name of the application(s) as they appear in the programs list. | ||
| SystemComponentOverride | Override | False | Switch | The default action of this script is to not remove any item that holds the SystemComponentregistry key at a value of 1. UsingSystemComponentOverride, you can bypass that default and remove items classified as system components. | |
| Switch | False | String[] | Specifies the custom switch(es) to be used during the uninstall process. This parameter is useful when the default silent switches do not work for a specific application. | ||
| Force | False | Switch | Forces the removal of the application using an aggressive approach if the normal uninstallation methods fail. | 
Output
- .\Remove-Application-log.txt
- .\Remove-Application-error.txt