In case it's useful to anyone, this code works well for me and it's resilient against non-VM systems which have some virtual devices. Unlike most code I've seen, it only reports a VM if it finds VM hardware in 2 or more different categories out of software (VM service processes), disk drives, BIOS ID and motherboard ID. So systems with virtual hard drive or an accidental match on some criterion are unlikely to trigger it by mistake. Uses code by fennek (link) At present it returns a string -