PowerShell, Scripting, wmi, WQL
Leave a comment

Finding file version from remote computer(s) using WMI

I came across this question on StackOverflow yesterday. The question was about finding the version details of a specific DLL from a list of remote computers. There are multiple ways to achieve this. The most easiest one would be to use PowerShell Remoting.

Update: My good friend and a PowerShell guru, @alexandair sent a message with the following trick to achieve this without  remoting or WMI (Of course, this trick works only if you have admin rights over the remote system):

This was my first answer to that question.

Now, what if you don’t have powerShell remoting enabled on these remote systems? A very valid scenario. This is where WMI can be used. Take a look at the following WMI query:

We are using CIM_DataFile WMI class to query the file information. The way query is written may look a bit complex but once you understand, it is really easy to build such queries. When this query gets executed — using Get-WMIObject

.. we will see output similar to:

As you see in the above output, there is a property called version. We can use this property to retrieve the version details of a file. Since we are using the Get-WMIObject cmdlet, we get the -ComputerName parameter along with it. So, the full solution to get the file version from remote computers will be:

Of course, this is not same as the above snippet using remoting. However, that isn’t tough to achieve. So, I have not included that in my answer. There are other methods too. I prefer using remoting or WMI. What is your preferred method? or Is there any other easier way to do this?

Filed under: PowerShell, Scripting, wmi, WQL


Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.