0

Summary of situation

I have some third party extension software for ArcGIS that I need to be able to uninstall with a powershell script. I have successfully installed and uninstalled a suite of software using the AppDeployToolkit for powershell but I am stuck trying to uninstall this one program. I am able to uninstall everything by running the MSI with an "Uninstall parameter". Unfortunately, this third party extension has no uninstall/remove option in the msi (no repair, remove, or uninstall options when I run it manually). It simply just tries to install again. I am, however, able to successfully uninstall from the 'Apps and Features' program GUI tool in windows.

Here are the things i've tried:

attempt A: Using the AppDeployToolkit

Execute-MSI -Action "Uninstall" -Path "Path\To\ArcFM.msi"

Output: Error: Application is already installed

attempt B: using WMI Object

$app = get-wmiobject -class win32_product |where-object {$_.Name -Match "ArcFM Solution Desktop*"}
$app.Uninstall()

Output: 1603 error (this is the error code for an installation error)

attempt C: using Uninstall-Package

$app = get-package -provider programs -includewindowsinstaller -name "ArcFM*
Uninstall-Package -Name $app

Output: Asks me to automatically install Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll. When I enter Y to automatically install I get this error...

Uninstall-Package : No package found for 'Microsoft.PackageManagement.Packaging.SoftwareIdentity'.
At line:1 char:1
+ Uninstall-Package -Name $arcfm2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package], Exception
    + FullyQualifiedErrorId : NoMatchFound,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

My Question

My overall questions is "How can I uninstall this software from powershell?"

But more specifically....

I CAN uninstall it from 'Apps and Feautures'. So when I use the GUI to do that, how exactly is windows executing the uninstall? It's not using the MSI and apparently not using wmi-objects either. It can't be using Uninstall-Package because it's not even installed on the machine. Is there a way for me to execute the same process that add/remove programs executes to uninstall from powershell? Is there a different way to uninstall software that I have missed?

Riley Hughes
  • 1,344
  • 2
  • 12
  • 22
  • 1
    There may not be a silent uninstaller. What does this say? `get-package arcfm | % { $_.metadata['uninstallstring'] }` – js2010 Nov 06 '19 at 19:50
  • If it's not an MSI package, then you will need to get the uninstall command line from the registry (i.e., the same thing that the `Apps and Features` applet uses) and run that. – Bill_Stewart Nov 06 '19 at 19:58
  • I gives me an index error because of a null array.... But if you are trying to see if I have an uninstall string in the registry I actually just found in regedit. Its a long code string prefixed with msiexec.exe and the `/i` parameter. When I paste it into powershell though it gives me the windows installer help window but doesnt execute anything – Riley Hughes Nov 06 '19 at 20:01
  • MsiExec.exe /I{7642F00E-69A2-4687-ADBD-4567A05FAF85} – Riley Hughes Nov 06 '19 at 20:03
  • 1
    Then it is, indeed, a Windows installer package. Run `msiexec /x "{guid}" /qb`. – Bill_Stewart Nov 06 '19 at 20:19
  • `get-package arcfm* | % { $_.metadata['uninstallstring'] }` try the wildcard – js2010 Nov 06 '19 at 20:21
  • If it's an msi provider, uninstall-package should work. – js2010 Nov 06 '19 at 21:53

1 Answers1

1

In a previous life, I used a fun product called PDQ to manage application deployments. One of the cool features of the product was that it pulled Product GUIDs for installed applications and built uninstallers for them. Here's how it did it:

# GUID is not unique across multiple computers, so pull it from the machine
$gui = Get-WMIObject Win32_Product | Where-Object -Property name -like "ArcFM*" | Select-Object -ExpandProperty IdentifyingNumber
# Use MSIexec.exe /x = uninstall /QN = silent
msiexec /x $guid

Hopefully that helps!

UPDATE I am editing the answer so that I can accept it. Removing th e /QN parameter from the final command. Placing it after the $guid variable may work too.

Riley Hughes
  • 1,344
  • 2
  • 12
  • 22
  • I really appreciate this way of retrieving the GUID rather than navigating regedit. My problem remains the same as where I left it in the comments to my OP above. the msiexec.msi opens the windows installer help window when I run the command you just gave me. Usually this happens when I'm missing a parameter? – Riley Hughes Nov 06 '19 at 20:09
  • Hey! this worked, however it would not work with the /QN parameter. I had to delete it. Maybe it needed to go after the $guid? In the past i've put silence parameters after the execution string rather than before. – Riley Hughes Nov 06 '19 at 20:16
  • 1
    Also, if you happen to be using Core, or are keeping this for later use "Get-CimInstance CIM_Product" replaces this functionality in PowerShell Core. Core does not contain the WMIObject cmdlets. – TheIdesOfMark Nov 06 '19 at 20:18
  • That's good information. I've been exploring core some as I work in Linux on my personal machine. – Riley Hughes Nov 06 '19 at 20:20
  • Yeah, sometimes quiet can be difficult. But the only program that's ever given me issues with msiexec is anti-virus. I'm not completely sure how it works, but i don't believe it uses the program's packaged msi for the uninstall. Or at least the behavior is often very different than the packaged msi. – TheIdesOfMark Nov 06 '19 at 20:22
  • This one is absolutely refusing to accept any of the quiet or passive parameters. It's forcing me to confirm the uninstall – Riley Hughes Nov 06 '19 at 21:57