Using PowerShell to determine whether Windows is running in a virtual machine

by Mitch Tulloch [Published on 14 Sept. 2011 / Last Updated on 14 Sept. 2011]

How to use Windows PowerShell to determine whether Windows is running in a virtual machine.

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 Windows PowerShell to do this provided you are dealing with a version of Windows that supports PowerShell. Here is a PowerShell function that can determine whether Windows is installed in a virtual machine on either Hyper-V or VMware:

Function isVM {

$objWMI = Get-WmiObject Win32_BaseBoard

$bln = ($objWMI.Manufacturer.Tolower() -match 'microsoft') -or ($objWMI.Manufacturer.Tolower() -match 'vmware')

return $bln}

If you have feedback concerning this tip, please email me. And be sure to check out my website!

Featured Links