# Trying to uninstall software

**URL:** <https://forums.powershell.org/t/trying-to-uninstall-software/11888>\
**Category:** PowerShell Help\
**Created:** [January 11, 2019, 2:45am UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888 "2019-01-11T02:45:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brydwatcher1966](https://avatars.discourse-cdn.com/v4/letter/b/c77e96/32.png) [@brydwatcher1966](https://forums.powershell.org/u/brydwatcher1966)\
**Post date:** [January 11, 2019, 2:45am UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/1 "2019-01-11T02:45:10Z")

</div>

hi,

I’m trying to uninstall software via powershell and have the following code:

[pre]

$SoftVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |  
Get-ItemProperty |  
Where-Object {$\_.DisplayName -match “avira” } |  
Select-Object -Property DisplayName, UninstallString

ForEach ($ver in $SoftVer) {

If ($ver.UninstallString) {

$uninst = $ver.UninstallString  
& cmd c/ “$uninst”  
}

}

[/pre]

It just runs and runs without doing anything. The result of $SoftVer is:

DisplayName UninstallString

* * *

Avira Software Updater MsiExec.exe /X{D4F0629A-3F4A-4098-ADFE-6F3551762251}  
Avira “C:\ProgramData\Package Cache{f71ab662-e492-44ad-9c93-e995ad4afb95}\Avira.OE.Setup.Bundle.exe” /uninstall

Has anyone any tips as to where I’m going wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [January 11, 2019, 7:21am UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/2 "2019-01-11T07:21:44Z")

</div>

not sure, but you could wait for the first one to get uninstalled before attempting the next one.

```
If ($ver.UninstallString) {
    $FilePath = ($ver.UninstallString -split './')[0]
    $Argument = ($ver.UninstallString -split ' ')[1]
    Start-Process -FilePath $FilePath -Argument "/$Argument" -Wait
}
```

---

<div class="post-metadata">

**Author:** ![fullenw1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/fullenw1/32/171_2.png) [@fullenw1](https://forums.powershell.org/u/fullenw1)\
**Post date:** [January 11, 2019, 9:20am UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/3 "2019-01-11T09:20:29Z")

</div>

Sometimes it does not work in remote sessions or it needs an elevated command prompt.

Did you have a look inside the **Setup** and **Application** event logs?  
Usually you have some information there about software installation and uninstallation.

---

<div class="post-metadata">

**Author:** ![conor](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@conor](https://forums.powershell.org/u/conor)\
**Post date:** [January 13, 2019, 4:17pm UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/4 "2019-01-13T16:17:25Z")

</div>

You could try uninstalling it by calling the Uninstall method on a WMI object

&nbsp;

```
$app = get-wmiobject -class WIN32_Product | where {$_.name -match "avira"}
$app.Uninstall()
```

&nbsp;

---

<div class="post-metadata">

**Author:** ![solidknight](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@solidknight](https://forums.powershell.org/u/solidknight)\
**Post date:** [January 14, 2019, 6:07am UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/5 "2019-01-14T06:07:05Z")

</div>

Not having worked with its uninstaller, I’d have to ask if the uninstaller requires user input. Uninstall strings aren’t always automatic and many times requires additional user input or additional command line parameters. Easiest way to determine this is to just open up an administrative shell and execute whatever is in the uninstall key. If it requires you to move forward, you need to figure out what additional parameters it needs.

On Windows 10 you can do:

```
Get-Package -Name "*Avira*" | Uninstall-Package
```

Again, only works if the uninstall string doesn’t need additional parameters to automate the uninstaller.

---

<div class="post-metadata">

**Author:** ![fullenw1](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/fullenw1/32/171_2.png) [@fullenw1](https://forums.powershell.org/u/fullenw1)\
**Post date:** [January 15, 2019, 3:01pm UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/6 "2019-01-15T15:01:18Z")

</div>

Adam Bertran made a very good module named **PSSoftware** and which is available on the PowerShell Gallery.  
You can use it for inventory with

```
Get-InstalledSoftware
```

But it has also several cmdlets for uninstalling software

```
Uninstall-InstallShieldPackage
Uninstall-ViaMsizap
Uninstall-WindowsInstallerPackage
Uninstall-WindowsInstallerPackageWithMsiexec
Uninstall-WindowsInstallerPackageWithMsiModule
```

For example, after finding the software’s GUID with **Get-InstalledSoftware** , you can uninstall it with the following command line

```
Uninstall-WindowsInstallerPackageWithMsiexec -Guid '{064A5FA2-8C86-4512-AD36-1EF114CCF58E}' -MsiExecSwitches '/qn'
```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/trying-to-uninstall-software/11888/7 "2024-05-16T20:33:25Z")

</div>

Closed on May 16, 2024, 8:33pm UTC


