A while back I responded to an internal (Microsoft) e-mail where someone had requested information about how to detect if a Windows OS is running on Hyper-V. It was a pretty good note, and Tony Soper posted it for me on his blog back in August of this year (http://blogs.technet.com/tonyso/archive/2009/08/20/hyper-v-how-to-detect-if-you-are-inside-a-vm.aspx).
Since it was posted, I received some questions about detecting more than just Hyper-V as a virtualization layer, and revisited the topic – with some help from others (like my buddy Ben who use VMware, Robin at Citrix, and Hashir at the Microsoft / Novell Joint Integration Lab in Cambridge). They helped by running specific WMI queries in virtual machines on various virtualization platforms, to help identify easy ways to differentiate the platforms from within a VM.
Originally, I went after baseboard (motherboard) information. The simplest way to do it is with WMIC (command line access to WMI). the following command:
wmic baseboard get manufacturer, product, Serialnumber, version
… would show something like this on a physical system:
…shows usable information for a physical system:
For VMware (ESX) the serialnumber was the telling element. it was prefaced with VMware
wmic bios get serialnumber
VMware-50 21 9a 15 90 33 ea fa-e8 4f 22 4a db a5 e1 33
I do not know how the serial number is created or what it represents for any of the virtualization layers, but at least I now have a one line command I can run inside my servers (wmic bios get serialnumber, version) to figure out if they are virtualized and what type of virtualization they are running on.