Jump to content


AJ82

How to determine is a machine is physical or virtual.

Recommended Posts

Hi All,

 

I have a perfectly working TS for deploying OSD on physical machines. What I am trying to achieve is to use the same TS and branch out if the condition is true:

 

IsVM equal to TRUE

or a WMI query:

http://social.technet.microsoft.com/Forums/systemcenter/en-US/d10c3e05-c211-45a6-859e-8c1ca2936430/vmware-tools-how-to-detect-a-virtual-machine

 

I have tried both the options but they do not work, please let me know if I am making a mistake.

 

Using:

SCCM 2007 R3

Windows 7 deployment on a VMware platform.

Virtual machine will be created using HW template using vCenter (which I don not care about).

Share this post


Link to post
Share on other sites

Here is the code that you can use to find whether your server is Physical or
VMWare box. This code uses Win32_ComputerSystem WMI class to query for
Manufacturer property. On Physical servers, this property will give you the
name of real manufacturer. While, on Virtual servers, it will give you
"VMWare Inc." for VMWare boxes.

'----------------------------------------------------------------------------
strComputer = "."

wscript.echo getMachineType(strComputer)

function GetMachineType(strComputer)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")

For Each objComputer in colSettings
strType = objComputer.Manufacturer
Next
if lcase(left(strType,6))="vmware" then
GetMachineType="V" 'Virtual VMWare Box.
else
GetMachineType="P" 'Physical Machine
end if
end function
'-------------------------------------------------------------------------

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...