Saturday, February 4, 2023

Finding Installed Applications (Get-ItemProperty vs. Get-WMIObject)

 Greetings everyone!

Forgive my absence.  I am working on my AZ-900 certification and there is a lot to learn!

This week I was given a list of servers.  I was tasked with getting all the applications installed on each of those servers.  So, I donned my PowerShell battle armor and faced the challenge.

First, I used the following code:
get-itemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-object DisplayName, DisplayVersion, Publisher, InstallDate | FT -AutoSize

This did give me a list of applications that had an Uninstall registry entry.  However, I know there were other programs that were not on the list.  So, I decided to use the following code:
Get-WmiObject -Class Win32_Product | Select-object Name | FT -AutoSize

It did give me more applications than the get-itemProperty code, but it took a lot longer for the list to appear.  The Get-itemProperty took 65 milliseconds.  The Get-WmiObject took 1 minute 22 seconds.

One article said to use Get-CIMInstance instead of Get-WmiObject in order to get a quicker response.  Get-CIMInstance took 1 minute and 37 seconds.  Oh, well.

I am still looking for a reason why the itemProperty command runs faster than the WmiObject command.  But, my main point is that there are two different ways to list what is installed on a computer, and that Get-WmiObject lists more installed apps than the other command.

As always, post a comment if you have any questions, or if you know why one is faster than the other.  I would appreciate it.  😀

Until next time...

1 comment: