Terms of Use For FixedByVonnie

By proceeding to access fixedByVonnie.com, you expressly acknowledge, and agree to, all of the following:

fixedByVonnie.com is a personal website and blog owned by Security Plus Pro LLC, which is being presented for informational purposes only. The views on this website are solely those of the website owner (and not those of any employer or of any professional associations affiliated with the website owner).  Any views expressed in this website and any information presented on this website, or in any of its blog entries, should not be relied on for any purpose whatsoever other than as the personal opinions of the website owner.  The website owner expressly disclaims any and all liability for any information presented on this site.  The owner of this website and its blog posts shall not be held liable, and shall be held harmless, for any errors or omissions in any information or representations contained in this website, or in any of its blog entries.  The website owner also expressly disclaims any liability for the current or future availability of any such information. The website owner makes no representations as to the accuracy or completeness of any information on this website or which may be found by following any link on this website. The website owner shall not be held liable for any losses, injuries, damages, claims, or causes of action, from the display or use of any information on this website or in any of its blog entries. If you use the information on this website, or on any of its blog entries, you do so solely at your own risk.

How to view all your installed programs with one mighty PowerShell command - fixedByVonnie

How to view all your installed programs with one mighty PowerShell command

This is one of those things that can be accomplished in a more direct route but it’s so cool that I need to show you how to do this.

Microsoft Powershell is an extremely nimble and robust command-line tool that lets you automate mundane tasks on local and remote machines.

The real power from Powershell stems from the command utilities that let you do stuff such as systems administration and importing data.

Today I just want to focus on one little command that lets you list all the programs currently installed on your computer.

Sure, you could take the circuitous path of pressing the Windows Key and typing

programs and features

Windows 8.1 Programs and Features

But I contend that using Powershell to accomplish the same task is the recondite path to geekhood.

We’re going to use the Get-WmiObject cmdlet to list all the programs currently installed on your computer. Then I’ll show you how to save the results to a file and we’ll finish with a neat trick that compares the installed programs between two PC’s.


 

Hit the Windows icon on your keyboard, and type:

powershell

You should the familiar blue icon appear in the search results.

Open it up and when the “BlueScreen of Life” appears type in the following command and wait about 5 seconds:

Get-WmiObject -Class Win32_Product

I call it the “BlueScreen of Life” because it’s the complete antithesis to its morbid cousin who loves to crash your computer: the notorious BlueScreen of Death.

The above Get-WmiObject command we typed above references the Win32_Product class which represents products as they are installed by the Windows installer.

Windows Powershell Win32_Product

But our results are less than satisfying.

The patent problem with this command is that it’s virtually unintelligible.  There’s way too much information and each software package is sorted by an arcane identifying number that is utterly useless to mere mortals like you and me.

Let’s tighten up our command a little bit:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name

Do you see that Select-Object -Property Name business?

We’re just telling PowerShell to refine the results to just the Name.  That is, we only care about the name of the application.  All that other crap about Vendor, Version and Caption is superfluous.

Windows PowerShell Select-Object

This is better but there are still two issues:

  1. Why are the programs still out of order?
  2. Why does Adobe Indesign CC 2014 show up in Programs and Features but not PowerShell?

The issue is that programs are still listed by the now invisible identifying number.  So how do we get it to sort by the application name?

Just pipe the results to the Sort-Object cmdlet by sticking it on the end of the last command:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name | Sort-Object Name

Windows 8.1 PowerShell Sort Object

Ahh, that’s better but Adobe Indesign CC 2014 is still missing from the list.

What’s up with that?

The Win32_Product class can only display applications installed using the Windows installer.  The Adobe application suite is provisioned through the Creative Cloud application suite which isn’t based on the Windows installer framework.  The concomitant result is that the Adobe product line doesn’t show up in our PowerShell output.

This is unfortunately one of the limitations of this PowerShell command; however, if you know how to list all the applications please let me know in the comments below.

So what else can you do besides shoot off an alphabetical list of most of your programs?

Well, you can pipe it to a text file by simply adding the greater than sign and the full path to a new file.  If the file doesn’t already exist, PowerShell will automatically create it for us.

Get-WmiObject -Class Win32_Product | Select-Object -Property Name | Sort-Object Name > C:\Users\vhudson\Desktop\desktop-apps.txt

Outputting PowerShell results to a file

Now if you want to compare the text files we can use the Compare-Object cmdlet with -ReferenceObject and -DifferenceObject to accentuate the differences between them.

Alright so I’ve got two files.

  • desktop-apps.txt shows all the windows installer based apps on my PC
  • peters-pc.txt has all the windows apps from a different PC

Here’s how to compare the two:

Compare-Object -ReferenceObject (Get-Content C:\Users\vhudson\Desktop\desktop-apps.txt) -Difference
Object (Get-Content C:\Users\vhudson\Desktop\peters-pc.txt)

This might look a little crazy but if you study it for a few seconds you can see I’m using the Get-Content cmdlet to grab the content of each text file and then the -ReferenceObject and -DifferenceObject options provide the reference points for the SideIndicator arrows.

Using Compare-Object to view differences in PowerShell

We defined the apps on my computer, desktop-apps.txt, as the reference set and the apps on Peter’s computer as the difference set.

In the SideIndicator column, when the arrow symbol points to the left like this (<=)  it means that the value, in this case the application name, only appeared in the reference set.

Similarly, where the arrow points to the right (=>) the application name only appeared in the difference set, Peter’s computer.  If both sets are identical you’ll see the == symbol.


That’s all there is to it.

One caveat is that you can keep using the Win32_Product class like we did in this tutorial; however, some experts say that it’s clunky and therefore not very efficient in a production environment.

Since we’re only using this on our local computer it shouldn’t be a big deal but it’s worth nothing that it might not be apt across networked environments.

According to Microsoft Scripting guru Ed Wilson, it’s more efficient to use the Win32Reg_AddRemovePrograms class like this:

Get-WmiOBject -Class Win32Reg_AddRemovePrograms

However Win32Reg_AddRemovePrograms isn’t a standard Microsoft class and is only available by installing System Center 2012.

Also known as System Center Configuration Manager, SCCM is a software suite that lets you do a bunch of remote administration stuff such as push software, install updates and run various reports.

SCCM used to be called Microsoft SMS but was rebranded as SCCM in 2007.

You’ll need to have this installed before you can start using Win32Reg_AddRemovePrograms.  If you don’t have it, don’t fret just keep using Win32_Product in non-production environments and you’ll be fine.

About

Connect with Vonnie on Twitter

Posted in Windows, Windows 7, Windows 8, Windows 8.1 Tagged with: ,
  • Jaeson Enumerabellon

    Can the WMIC command for CMD cater all the powershell commands you showed above.???

  • Jaeson Enumerabellon

    Did you found any ways to solve the above problem you stated regarding adobe indesign??

  • AceyMan

    Your explanation of the pipeline is good and helpful, but — it’s now recommended to avoid queries to the Win32_Product class. Doing so has… side effects.

    Citations,

    https://support.microsoft.com/en-us/kb/97452
    http://myitforum.com/cs2/blogs/gramsey/archive/2011/01/25/win32-product-is-evil.aspx
    https://sdmsoftware.com/group-policy-blog/wmi/why-win32_product-is-bad-news/

  • Heath Fournier

    I agree with AceyMan. Querying Win32_Product is not advised. I wrote a script that incorporated a query similar to this as well, as looking in Program Files and various other reg locations to find software, but the query to Win32_Product ended up causing problems that the links AceyMan provided. Unfortunately finding installed software is an ongoing issue with Windows. If there’s an easy way to get a complete list, I don’t know it.

  • Marc Graham

    you can use the registry to pick Adobe up:

    Get-ItemProperty HKLM:SoftwareWow6432NodeMicrosoftWindowsCurrentVersionUninstall* | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize

    • Andrew Turner

      Thanks Marc
      Works well and shows stuff pushed to the PC and not installed using Windows installer. Some help on how to extend to remote machines would be a huge benefit.

      I am a newbie but guess some kind of for …..next loop using the AD Computer containers might work but I have absolutely no idea how to do this.

      • James Elie

        For remote machines:

        Invoke-Command -cn -ScriptBlock {}

        Put the Get-ItemProperty command from Marc inside of the {}. I can’t remember if you only need to enable the WinRM service, or if you need to enable full PowerShell remote capabilities:

        Get-Service -name WinRM -computername | start-service
        OR
        Enable-PSRemoting

        The Enable-PSRemoting command opens access through the firewall as well, but as with enabling any remote access / remote administration, the computer is now available to the outside world. It should be limited to just administrators, but as always, use with caution. You never know which admins are using crappy passwords.

        You can edit the firewall rule created by Enable-PSRemoting to restrict network access down to a small list of IP addresses that correspond to the administrator PCs if that helps.

    • Matthew Pitts

      How can you uninstall a program that doesn’t show with win32_product using powershell?

  • Abhishek Kumar Sahu

    how do i get for last 30 days

  • senthil

    How to discriminate the .msu or .exe softwares are installed using powershell

  • Vincent Francis

    Using http://www.action1.com you can query all your endpoints for the list of installed software and filter by program name (e.g. which of your endpoints have a certain program installed). They offer freeware for up to 100 endpoints.

  • Vincent Francis

    You can go further and query all computers in an AD domain for list of installed software:
    Get-ADComputer | ForEach-Object {Get-WmiObject -Class Win32_Product -Computer $_.Name}

    Here is detailed description of the syntax: https://www.action1.com/kb/list_of_installed_software_on_remote_computer.html

  • eraykaya Kaya

    Have a look at this queries SCCM database “list-software-inventory-items-of-computers-discovered-by-sccm”:

    https://bestitsm.wordpress.com/2018/06/29/list-software-inventory-items-of-computers-discovered-by-sccm/