WMI is a powerful feature. Remember that WMI is CMI and CMI is WMI. In this blog post I am going to play with WMI Objects on the local computer and on remote computers. If you want to do an inventory of all installed software in your active directory domain, then keep on reading my post.
Get-WmiObject vs. Get-CimInstance
WMI and CIM is a definition of management information. Vendors use WMI to provide their informations. In this article we will concentrate on the class win32_product. The win32_product class provides information of all installed software. But there are differences between Get-WmiObject and Get-CimInstance.
The output
Get-WmiObject win32_product
Get-CimInstance win32_product
The output is different. But it’s not the only variation.
Browsing classes
Get-CimInstance enables you to browse all possible classes by pressing TAB or to type win32_ and press CTRL + Space. You get warned: “Are you sure you want to show all of them?” 😉 Yes, you are.
I think it’s better to proceed with Get-CimInstance.
Getting all installed software on the local host
As promised, we concentrate on gathering information of installed software. To do so, I recommend modifying the output. What are the most important informations and how to get them? Simply run Get-Member to explore all properties.
I’ve highlighted some of them which are in my view the most important ones. To get a better screen I send the output to Out-GridView.
Get-CimInstance win32_product | Select-Object Name, PackageName, InstallDate | Out-GridView
Nice. So we have a list of our currently installed software. Let’s go to the bigger challenge: To retrieve a list of software from remote computers.
Get installed Software from Remote Computers
Make sure WinRM is enabled on your computers. WinRM is enabled by default on Windows Server 2012/2016, but not on Client operating systems. More about enabling WinRM in this article:
Ok, my testing environment is very small. I only have 2 computers (server02 and client01). Let’s get the Computer Names from Active Directory from a specific OU and then run Get-CimInstance against them.
(Get-ADComputer -Filter * -Searchbase "OU=Test,DC=sid-500,DC=com").Name | Out-File C:\Temp\Computer.txt | notepad C:\Temp\Computer.txt
Review your list carefully. Now we call the shots. Here we go.
Get-CimInstance -ComputerName (Get-Content C:\Temp\Computer.txt) -ClassName win32_product -ErrorAction SilentlyContinue| Select-Object PSComputerName, Name, PackageName, InstallDate | Out-GridView
Have fun documenting your environment!
See also
PowerShell: Getting RAM Info by manufacturer, speed, serial number and capacity
Categories: PowerShell, Windows Server
I’m getting this error. Google isn’t all that helpful Any ideas?
Get-CimInstance : The WS-Management service cannot process the request because port :5985/wsman is invalid.
LikeLike
Remove the -ErrorAction parameter and see what happens. Then you will see an error code to build on.
LikeLike
Hi,
I am using this cmd as follows
Get-CimInstance -ComputerName (Get-Content .\ComputerList.csv) -ClassName win32_product -ErrorAction SilentlyContinue| Select-Object PSComputerName, Name, PackageName, InstallDate | Out-GridView
this seems to work for the first computer only, it does not seem to do a foreach
also how do i export this to a csv file?
LikeLike
Hi there,
unfortunately this is not complete! This only list software installed with an .msi file.
In the registry you have to look in these both locations to have ALL installed software:
->HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall
->HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
LikeLike
Great web site you have got here.. It’s difficult to find excellent writing like yours these days.
I honestly appreciate people like you! Take care!!
LikeLike
Thank you for the kind words.
LikeLike
How to get a AD computers list with installed applications or specific application
LikeLike