6

We've used the following command found at this link to try and get a complete listing of installed programs in Windows:

Get-WmiObject -Class Win32_Product 

However, this gives an incomplete listing of installed programs when compared with the list of installed programs in the Control panel.

Our original intention is to have a script that can interactively and eventually automatically uninstall bloatware installed on a computer. However, the command above misses a handful that we'd like to have uninstalled as well.

Is there another Class we can look into in order to get the complete listing? Or is there another command altogether that we can use? Any insight is appreciated

rm-vanda
  • 3,122
  • 3
  • 23
  • 34
  • 1
    if you have SCCM installed, you can use the class that it adds. the other method is to check the install/uninstall items in the registry. ///// as an aside, you likely otta try to avoid `Win32_Product` when you can - it runs an integrity check on ALL the apps it know of ... and sometimes silently resets them to the default config. ouch! – Lee_Dailey Nov 05 '18 at 19:44

2 Answers2

10

The Get-Package cmdlet provides more information than the Win32_Product class. Here are the differences between the two on my Windows 10 system:

PS C:\> Get-WmiObject -Class Win32_Product | Where-Object Name -Match TOSHIBA | Format-Table

IdentifyingNumber                      Name                        Vendor              Version      Caption
-----------------                      ----                        ------              -------      -------
{1E6A96A1-2BAB-43EF-8087-30437593C66C} TOSHIBA System Driver       Toshiba Corporation 2.00.0005    TOSHIBA System Driver
{1515F5E3-29EA-4CD1-A981-032D88880F09} TOSHIBA Audio Enhancement   Toshiba Corporation 3.0.0.9      TOSHIBA Audio Enhancement
{716C8275-A4A9-48CB-88C0-9829334CA3C5} Toshiba Quality Application TOSHIBA             1.0.9.7      Toshiba Quality Application
{E4C7D9D7-19D4-4623-AF0C-EA313C466411} Toshiba TEMPRO              Toshiba Europe GmbH 5.0.0        Toshiba TEMPRO
{72EFCFA8-3923-451D-AF52-7CE9D87BC2A1} TOSHIBA eco Utility         Toshiba Corporation 3.0.1.6403   TOSHIBA eco Utility
{B040D5C9-C9AA-430A-A44E-696656012E61} TOSHIBA System Settings     Toshiba Corporation 3.0.3.6400   TOSHIBA System Settings
{0B39C39A-3ECE-4582-9C91-842D22819A24} TOSHIBA Display Utility     Toshiba Corporation 2.0.1.0      TOSHIBA Display Utility
{EDC626BA-3E59-44C4-96B4-9066E29BF600} TOSHIBA Service Station     Toshiba Corporation 3.1.0.2      TOSHIBA Service Station
{26BB68BB-CF93-4A12-BC6D-A3B6F53AC8D9} TOSHIBA Password Utility    Toshiba Corporation 8.1.1.0      TOSHIBA Password Utility
{B507386D-1F61-4E55-B05B-F56ACB0086B3} TOSHIBA PC Health Monitor   Toshiba Corporation 5.01.02.6400 TOSHIBA PC Health Monitor

This one includes extra entries. You should be able to see that it includes entries from the Programs provider as well as the msi provider.

PS C:\> Get-Package *TOSHIBA*

Name                           Version          Source                           ProviderName
----                           -------          ------                           ------------
TOSHIBA System Driver          2.0.5            C:\Program Files (x86)\TOSHIB... msi
TOSHIBA Audio Enhancement      3.0.0.9          C:\Program Files\TOSHIBA\TOSH... msi
Toshiba Quality Application    1.0.9.7          C:\Program Files (x86)\Toshib... msi
Toshiba TEMPRO                 5.0.0            C:\Program Files (x86)\Toshib... msi
TOSHIBA eco Utility            3.0.1.6403       C:\Program Files\TOSHIBA\Teco\   msi
TOSHIBA System Settings        3.0.3.6400       C:\Program Files\TOSHIBA\Syst... msi
TOSHIBA Display Utility        2.0.1.0          C:\Program Files\Toshiba\TOSH... msi
TOSHIBA Service Station        3.1.0.2                                           msi
TOSHIBA Password Utility       8.1.1.0          C:\Program Files\Toshiba\Pass... msi
TOSHIBA Password Utility       8.1.1.0                                           Programs
TOSHIBA PC Health Monitor      5.1.2.6400       C:\Program Files\TOSHIBA\TPHM\   msi
TOSHIBA Manuals                10.20                                             Programs
TOSHIBA Recovery Media Creator 3.3.00.8003                                       Programs

Deleting packages from the Programs provider is actually harder than might sound in the first place. Entries in there will generally have an uninstall command or a quiet uninstall command but it's not guaranteed. For cases where there is a quiet uninstall string then you could do something like this:

function Uninstall-Program($Package) {

    $Command = foreach ($i in (0..($Package.Meta.Attributes.Keys.Count - 1))) {
        if ($Package.Meta.Attributes.Keys[$i] -eq 'QuietUninstallString') {
            $Package.Meta.Attributes.Values[$i]
        }  
    }

    Invoke-Expression "& $Command"
}

Then you could uninstall with:

$Package = Get-Package "botframework-emulator"
Uninstall-Program $Package
Don Cruickshank
  • 5,641
  • 6
  • 48
  • 48
  • That's excellent! And certainly answers the question - however, it doesn't seem like we can use the objects returned by that method to uninstall the programs in question. Know of any way to do that last bit? – rm-vanda Nov 05 '18 at 20:17
  • 1
    @rm-vanda could you use `Uninstall-Package -name packageName` – ArcSet Nov 05 '18 at 20:36
  • 1
    The `Uninstall-Package` cmdlet won't work for some entries. I've added a section for handling entries in Programs control panel. – Don Cruickshank Nov 05 '18 at 21:13
  • If the package doesn't have a "QuietUninstallString", one may check each keys to find a uninstall string. – Hamza Ince Nov 07 '22 at 10:20
0

I had the same issue, ended up using: Get-WmiObject -Class Win32_InstalledWin32Program