Share via


Script to Inventory VM Guest OSes – Updated

The other day a colleague asked me how to use PowerShell to gather information about what operating system was running inside of each virtual machine on a Hyper-V server.  I went to point them to this blog post: Scripts to Inventory Virtual Machines [Hyper-V].  But then realized that there were two problems:

  • This script uses the v1 WMI namespace – so will only work on Windows Server 2008, 2008 R2 and 2012 hosts
  • This script is still using the old WMI v1 client APIs

So – here is an updated version:

Just like the last one, this will produce a nicely formatted table of what virtual machines are running, and what operating system is inside them.

Cheers,

Ben

Comments

  • Anonymous
    September 12, 2016
    The comment has been removed
  • Anonymous
    September 13, 2016
    Currently in MS Hyper-V Server 2012R2 the WMI calls to get all the VM related information are very slow. Just to get a msvm_computersystem related informatin takes over 1 sec, another 1sec for all msvm_virtualsystemsettingdata and lots more for networking. We have tried MS Hyper-V Server 2016 with the VMCX binary config files but there was not seed improvment noticable. What is the most efficient way to read (not write) current VM configuration information ? We are trying to obtain live information about VM in real time. Are there plans to opensource or document the VMCX format in order to be able to write a parser for it ?
  • Anonymous
    September 20, 2016
    comment