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.