1

I'm opening PowerShell as Administrator.

I run:

Get-Package *notepad*

And PowerShell shows me Notepad++ (32-bit x86)

I then run:

Get-Package *notepad* | Uninstall-Package -Force

And PowerShell is not uninstalling Notepad++

I tried with a few programs, they are still all installed. Why?

EDIT: as you can see @m0lochwalker PowerShell is acting like the program was uninstalled.

enter image description here

Try on your environment, nothing gets uninstalled.

@Ranadip Dutta: Get-WmiObject -class Win32_Product works for 32-bit only and doesn't return Notepad++ if it's 64-bit; Basically it doesn't return any 64-bit at all:

enter image description here

I need something more comprehensive that could work both with 32-bit and 64-bit

5
  • Use something like $program = Get-WmiObject -class Win32_Product | ? {$_.Name -eq “your program”} ...then $program.uninstall() Feb 18, 2019 at 3:44
  • What is the error you are getting ? or just directly it is giving the control back in the shell without anything ? Feb 18, 2019 at 4:29
  • I think this is a bug/feature of uninstall-package. If the provider name is Programs, then the cmdlet will not uninstall it. It means you did not use the package manager to install the program initially Feb 18, 2019 at 12:50
  • Francesco - your comments about the Win32 _Product class are incorrect. Why don’t you try my command in your environment. Feb 18, 2019 at 14:40
  • @m0lochwalker: I tried your command and you can see by the picture, is not working. Try to run Get-WmiObject -class Win32_Product | select Name and you will discover that a lot of your programs are missing Feb 18, 2019 at 21:18

1 Answer 1

1

Get-WmiObject -class Win32_Product is an old dinosaur that must die.

Get-Package is probably broken and I flagged it to the official Microsoft repository

In the meantime Mike F Robbins helped me understanding how rotten Win32_Product is and he drove me to this awesome post where you can copy paste the code into a test.ps1 file and install it into your PowerShell system by doing . .\test.ps1

Now you have installed the Get-Software method that will help you dive into your programs at a light speed (not like Win32_Product).

Now I can use:

Get-Software | Where-Object { $_.DisplayName -like "*Notepad*" } | Format-Table

to see Notepad++ and I can uninstall it using the UninstallString

enter image description here

Is not what I wanted but is the closest working thing that I found. Feel free to add a new reply if you find a better one.

EDIT: There was indeed a bug and Microsoft is resolving it.

For now you can use:

get-package *notepad* |% { & $_.Meta.Attributes["UninstallString"]}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.