If you need to determine whether a particular instance of a Windows operating system is installed on a physical machine or a virtual machine, you can use the Windows Management Instrumentation Command-line (WMIC) to do this provided you are dealing with a version of Windows that supports PowerShell. Here is a WMIC command that can determine whether Windows is installed in a virtual machine either Hyper-V, VMware or Xen:
wmic bios get serialnumber, version
For virtual machines running on Hyper-V, the version parameter will include the string VERSION.
For virtual machines running on VMware, the serialnumber parameter will include the string VMware.
For virtual machines running on Xen, the version parameter will include the string Xen.