Skip to content

Instantly share code, notes, and snippets.

@kayasax
Last active September 15, 2015 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kayasax/8ad1405cd0ba97becc31 to your computer and use it in GitHub Desktop.
Save kayasax/8ad1405cd0ba97becc31 to your computer and use it in GitHub Desktop.
Determine if powershell runs within a virtual machine.
function isVM{
(gwmi win32_bios).version -match "vrtual"
}
or (from http://www.windowsnetworking.com/kbase/WindowsTips/Windows7/AdminTips/VirtualPlatforms/UsingPowerShelltodeterminewhetherWindowsisrunninginavirtualmachine.html)
Function isVM {
$objWMI = Get-WmiObject Win32_BaseBoard
$bln = ($objWMI.Manufacturer.Tolower() -match 'microsoft') -or ($objWMI.Manufacturer.Tolower() -match 'vmware')
return $bln}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment