vCO Workflow Script to Find a vCAC Virtual Machine Object by Name

The following code finds a vCAC virtual machine object by name

 

 

var strVirtualMachineID;
	strVirtualMachineID = "";

var arrVCACVirtualMachines;
	arrVCACVirtualMachines = Server.findAllForType("vCAC:VirtualMachine");   

var vCACVM = null;  

for (var i = 0; i < arrVCACVirtualMachines.length; i++)
{
	var objVCACVirtualMachine;
		objVCACVirtualMachine = arrVCACVirtualMachines[i];

    if (objVCACVirtualMachine.virtualMachineID == strVirtualMachineID)
	{
        vCACVM = objVCACVirtualMachine;

        break;
    }
}

System.log(vCACVM);

Leave a Reply