To uninstall an application using PowerShell on Windows, you can use the Get-WmiObject
cmdlet to query for the installed application and then invoke its uninstall method. Here's a step-by-step guide:
Identify the Application Name or GUID:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
.Open PowerShell:
Uninstall the Application:
Get-WmiObject
cmdlet to locate and uninstall the application. Replace ApplicationName
with the name or GUID of the application you wish to uninstall.# Replace 'ApplicationName' with the actual name or GUID of the application $appName = 'ApplicationName' # Find the application by Name or GUID and uninstall $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName } $app.Uninstall()
Uninstall-WindowsFeature
cmdlet for Windows features and roles.Uninstall-WindowsFeature -Name 'ApplicationName'
Let's say you want to uninstall an application named "ExampleApp":
# Find and uninstall application named 'ExampleApp' $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq 'ExampleApp' } $app.Uninstall()
Name vs. GUID: The -eq
operator in Where-Object
can match either the application name or the GUID depending on what you have.
Administrative Privileges: PowerShell must be run with administrative privileges (Run as administrator
) to successfully uninstall applications.
Handling Errors: PowerShell might throw errors if the application is not found or if there are issues during the uninstallation process. Ensure to handle exceptions or errors appropriately in your script.
Alternative Methods: In some cases, applications may not be listed in Win32_Product
class due to various reasons (e.g., MSI-based installations, applications not registered properly). In such cases, you might need to use different methods or utilities specific to that application's uninstallation process.
By following these steps, you can effectively uninstall applications using PowerShell on Windows, providing a scriptable and efficient way to manage software installations across multiple systems. Adjust the script based on your specific application's name or GUID and handle any errors or edge cases as needed.
How to uninstall an application using PowerShell on Windows?
Description: This query addresses the basic steps to uninstall an application using PowerShell cmdlets.
# Uninstall an application using its name $appName = "AppName" Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName } | ForEach-Object { $_.Uninstall() }
How to uninstall a program using its GUID in PowerShell?
Description: This query explains how to uninstall a program using its unique GUID.
# Uninstall an application using its GUID $appGUID = "{GUID-OF-THE-APPLICATION}" $uninstallKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$appGUID" $uninstallString = (Get-ItemProperty $uninstallKey).UninstallString Start-Process "cmd.exe" -ArgumentList "/c", $uninstallString -Wait
How to force uninstall an application using PowerShell?
Description: This query addresses how to force uninstall an application using PowerShell.
# Force uninstall an application $appName = "AppName" Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName } | ForEach-Object { $_.Uninstall() }
How to uninstall multiple applications using PowerShell?
Description: This query covers uninstalling multiple applications in one script using PowerShell.
# Uninstall multiple applications $appNames = @("AppName1", "AppName2", "AppName3") foreach ($appName in $appNames) { Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName } | ForEach-Object { $_.Uninstall() } }
How to uninstall a Windows Store app using PowerShell?
Description: This query explains how to uninstall a Windows Store app using PowerShell.
# Uninstall a Windows Store app $appPackageName = "Microsoft.WindowsCalculator" Get-AppxPackage -Name $appPackageName | Remove-AppxPackage
How to uninstall applications on remote computers using PowerShell?
Description: This query covers uninstalling applications on remote computers using PowerShell.
# Uninstall applications on a remote computer $remoteComputer = "RemotePCName" $appName = "AppName" Invoke-Command -ComputerName $remoteComputer -ScriptBlock { Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $using:appName } | ForEach-Object { $_.Uninstall() } }
How to get a list of installed applications using PowerShell?
Description: This query addresses getting a list of all installed applications using PowerShell.
# Get a list of installed applications Get-WmiObject -Class Win32_Product | Select-Object -Property Name, Version
How to uninstall an application with a specific version using PowerShell?
Description: This query covers uninstalling an application with a specific version using PowerShell.
# Uninstall an application with a specific version $appName = "AppName" $appVersion = "1.0.0" Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName -and $_.Version -eq $appVersion } | ForEach-Object { $_.Uninstall() }
How to silently uninstall an application using PowerShell?
Description: This query explains how to silently uninstall an application using PowerShell.
# Silently uninstall an application $appName = "AppName" $uninstallPath = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$appName").UninstallString Start-Process "cmd.exe" -ArgumentList "/c", "$uninstallPath /quiet" -Wait
How to log uninstallation details using PowerShell?
Description: This query covers how to log the details of the uninstallation process using PowerShell.
# Log uninstallation details $appName = "AppName" $logFile = "C:\UninstallLog.txt" $app = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq $appName } if ($app) { $app.Uninstall() | Out-File -FilePath $logFile -Append Add-Content -Path $logFile -Value "$appName uninstalled successfully." } else { Add-Content -Path $logFile -Value "$appName not found." }
request-timed-out touchpad math observable android-viewbinding distutils file-uri .net-core reportviewer robo3t