- Get-Package "Google Chrome" | % { & ($_.Meta.Attributes["UninstallString"] -replace '"') /S
This command uninstalls other software except Google chrome , provider is programs. I have tried many things but this does not work. Please help
This command uninstalls other software except Google chrome , provider is programs. I have tried many things but this does not work. Please help
You say that your Google Chrome installation was performed via the Programs
package-management provider, rather than via the msi
provider (for the latter, see the bottom section).
Assuming that $_.Meta.Attributes["UninstallString"]
has a value, it contains a string that contains a no-shell / for-cmd.exe
command line, which often will not work when executed directly from PowerShell with Invoke-Expression
, because PowerShell has more metacharacters than cmd.exe
that require quoting, notably {
and }
, as used in GUIDs.
&
, the call operator does not support executing whole command lines, it expects only the name or path of a command or executable, optionally followed by arguments.In the simplest case, you can do the following:
Get-Package 'Google Chrome' | % {
cmd /c ($_.Meta.Attributes['UninstallString'] + ' /S')
}
For more information, see this answer.
IF your Google Chrome was installed via the msi
package provider (verify with: (Get-Package 'Google Chrome').ProviderName
):
Not all installed programs have an UninstallString
attribute (and even fewer have a QuietUninstallString
one), and an msi
-provider-installed Google Chrome doesn't have one.
However, you should be able to pipe to Uninstall-Package
for silent (unattended) uninstallation:
Get-Package 'Google Chrome' | Uninstall-Package