In my powershell code it is tasked to remove google crhome. The code compiles however it states Google Chrome is not installed on the PC. However Google Chome is installed on the PC. I dont understand why it is not being reconginized. Any idea what to do next?
# Define the application name
$appName = "Google Chrome"
# Get the application details from the registry
$app = Get-WmiObject -Query "SELECT * FROM Win32_Product WHERE Name = '$appName'"
if ($app) {
Write-Output "Uninstalling $appName..."
# Uninstall the application
$app.Uninstall() | Out-Null
if ($?) {
Write-Output "$appName has been successfully uninstalled."
} else {
Write-Output "Failed to uninstall $appName."
}
} else {
Write-Output "$appName is not installed on this machine."
}
New contributor
John Z is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.