Detecting The Virtualization Layer From Within A Guest / Child Instance

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 (

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:

wmic bios get serialnumber, version

…shows usable information for a physical system:

wmic bios get version
Xen – 0s

VMware Results

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.

Comments (1)

  1. danovich_ says:

    Powershell query:

    $Result = $null

    $bios = gwmi Win32_BIOS  | Select-Object "version","serialnumber"

    if($bios.Version -match "VRTUAL") {$Result = "Virtual – Hyper-V"}

    elseif($bios.Version -match "A M I") {$Result = "Virtual –  Virtual PC"}

    elseif($bios.Version -like "*Xen*") {$Result = "Virtual – Xen"}

    elseif($bios.SerialNumber -like "*VMware*") {$Result = "Virtual – VMWare"}

    else {$Result = "Physical"}

    write-host $Result