I\'m remoting desktop to windows servers in our Lab/datacenter. I have a requirement to figure out all our servers are virtual machines or physical servers programatically,
As far as I know there is no easy way to do this.
There are a few workarounds but there is, at least as far as I know, not a one-size-fits-all solution.
Ben Armstrong wrote a post about Detecting Microsoft virtual machines and there's a low-level trick which can determine whether you are running within a Virtual PC or VMWare but that still leaves out VirtualBox and others.
A trick you might want to try is to detect whether VMWare Tools or VirtualBox Tools are installed. In most cases they are installed on the guest OS to provide needed features but it will be hard to maintain the different installation GUIDS on your end so it's not an ideal solution.
--- Also , if the VM is running in a Linux KVM environment, the output is like this one
