2

I have a 3rd party agent installed on my virtual machines that I need to remove using Powershell.

It shows up in control panel, add/remove programs but does not show up using either get-wmiobject or the get-itemproperty hklm uninstall registry key path:

get-itemproperty HKLM:\\software\microsoft\windows\currentversion\uninstall* | select-object displayname, displayversion, publisher

Anyone else know a way that I can remove it using a script?

5
  • I'd check the registry again, as the add/remove list is held in the registry. Maybe try regedit and use 'find' in that key. Commented Oct 30, 2018 at 11:34
  • and how would i remove the package using powershell ? Commented Oct 30, 2018 at 12:46
  • First find the app in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. Then look for an entry called UninstallString. If the app was installed using a .MSI file, the UninstallString will look like this: MsiExec.exe /I {<GUID>}. In that case, change the string to MsiExec.exe /X {<GUID>}. (In a cmd box type msiexec.exe /? for all other options). The Uninstall string could also point to an .EXE file. Read here how to run a command in PS. Commented Oct 30, 2018 at 14:28
  • It would help if you included your code for get-wmiobject and get-itemproperty, we could see if you've simply made a mistake rather than having to guess what you're doing or what's wrong... always include code in your questions, even if it doesn't work it helps us know what you're trying to do :) Commented Oct 30, 2018 at 14:50
  • Have you tried Get-WmiObject -Class Win32_Product | Where-Object { $_.PackageName -like "*yourPgkName*" }? Commented Oct 30, 2018 at 16:11

5 Answers 5

5

In the future include any code you've tried, even if it doesn't work! Just listing the names of the commands you tried isn't very useful as we can't see what you're doing so have to guess. You've had comments and an answer that wasn't relevant because of this.


Now you've finally shown your code (I've edited your answer to include it as it was hidden in a comment), I can see that you're only checking one of the two Uninstall key locations.

On a 64bit OS (most computers these days) there are two places for these:

  • HKLM:\SOFTWARE\Microsoft [..]
  • HKLM:\SOFTWARE\Wow6432Node\Microsoft [..]

Here's an example on how to search them for firefox:

$RegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall", "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"

$app = Get-ChildItem -Path $RegPath | Get-ItemProperty | Where-Object {$_.DisplayName -match "firefox" }

You can then execute either $app.QuietUninstallString or $app.UninstallString - you may not have both available it depends on the application.

Sign up to request clarification or add additional context in comments.

1 Comment

It's worth to add not all software offer QuietUninstallString
1

This should work if was an msi installer (powershell 5.1). Powershell 7 does not support msi or programs providers.

get-package *softwarename* | uninstall-package

Or with the programs provider, you could probably see the uninstallstring, but have to add more for a silent uninstall, like "/S".

get-package *softwarename* | % { & $_.metadata['uninstallstring'] /S } 

Comments

1

Just to add to Henrycarteruk's post, you can pipe the commands to cmd to execute the uninstall strings.

$app.QuietUninstallString | cmd

Comments

0

Try:

 $installedMsiObject = Get-WmiObject -Class Win32_Product | Where-Object { $_.PackageName -like "*YourPkgName* }
 if ($installedMsiObject) {
    try {
       $installedMsiObject.UnInstall() | Out-Null
    }
    catch {
       Write-Error "Error occurred: $_"
    }
 }

5 Comments

guys - as i mentioned in the question , the application does not show up using get-wmiobject so i cant use any code that uses that.
here is my get-item code get-itemproperty HKLM:\\software\microsoft\windows\currentversion\uninstall* | select-object displayname, displayversion, publisher . This code gives back 8 applications , none of which are the one i need.
The application is not installed using .msi so it wont show up in the uninstall registry key i presume
HOW is it installed?
its called OCS ocsinventory-ng.org/en . Its a .exe package
-1

This is an old post but responding here in case it helps somebody else. I beat my head on this for days ...

In addition to the [2] HKLM registry paths referenced above (one for 32-bit registry and the other for 64-bit registry), you also need to look at HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall in order to query "per-user" installs. Applications like Chrome, MS Teams, Zoom, ReadyTalk Desktop, etc) install by default as "per-user". You will not find the installer / uninstaller information under HKLM.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.