If you are working with locally running VMs like VMware Player / Workstation or Hyper-V, you know it can get really hard to keep track which VMs are running on your clients. Based on my Inventory solution based on an Azure Cosmos DB, I wrote a sample script to collect the required information.

Basics
To collect the data, I will use the backend from my reporting series: https://mikemdm.de/2023/04/30/powerbi-reports-for-advanced-windows-client-inventory-data-part-1/
In that series we used this remediation script to collect basic information about our clients: https://github.com/mmeierm/Scripts/blob/main/Inventory/ProactiveRemediation.ps1
I added the logic to inventory the local VMs to that script and uploaded it as a separate version: Scripts/Inventory/ProactiveRemediation_with_local_VMs.ps1 at main · mmeierm/Scripts
Script insights
The script searches for VMware Player or Workstation VMs in a specific location defined in the “$VMPath” variable:

As well as for all users in the Inventory files for VMWare Player:

And VMware Workstation:

And if available all Hyper-V VMs:

Result
As a result, we get an array containing all available information about locally running VMs:

This information will then be uploaded to our Azure Cosmos DB as we know from all other Inventory properties from our reporting series before:

We can then use this data in PowerBI:

Conclusion
With this addition to the Custom Inventory, we now have more insights to our VM fleet on our clients. Stay tuned for the next part, where I will show you the first version of my VDI Manager, which will be the counter part on the clients to give your users insights about the VMs.

Leave a Reply