vCO Workflow Script to Find a Virtual Machine DRS Group and Add New Virtual Machines
var objVcClusterVmGroup; objVcClusterVmGroup = new VcClusterVmGroup(); var objVcClusterConfigInfoEx; objVcClusterConfigInfoEx = objVCClusterComputeResource.configurationEx; var arrVcClusterGroupInfo; arrVcClusterGroupInfo = objVcComputeResourceConfigInfo.group; for ( var i = 0; i < arrVcClusterGroupInfo.length; i++ ) { var objVcClusterGroupInfo; objVcClusterGroupInfo = arrVcClusterGroupInfo[i]; if (objVcClusterGroupInfo instanceof VcClusterVmGroup) { if (objVcClusterGroupInfo.name == strDistributedResourceSchedulerName) { objVcClusterVmGroup = objVcClusterGroupInfo; exit; } } } var arrVCVirtualMachine; arrVCVirtualMachine = objVcClusterVmGroup.vm; for ( var i = 0; i < arrVCVirtualMachineNew.length; i++ ) { var objVCVirtualMachine; objVCVirtualMachine = arrVCVirtualMachineNew[i]; arrVCVirtualMachine.push(objVCVirtualMachine); } objVcClusterVmGroup.vm = arrVCVirtualMachine; var objVcClusterGroupSpec; objVcClusterGroupSpec = new VcClusterGroupSpec(); objVcClusterGroupSpec.operation = VcArrayUpdateOperation.edit; objVcClusterGroupSpec.info = objVcClusterVmGroup; var objVcClusterConfigSpecEx; objVcClusterConfigSpecEx = new VcClusterConfigSpecEx(); var arrMyVcClusterGroupSpec; arrMyVcClusterGroupSpec = new Array(); arrMyVcClusterGroupSpec[0] = objVcClusterGroupSpec; var objVcClusterDrsConfigInfo; objVcClusterDrsConfigInfo = new VcClusterDrsConfigInfo(); objVcClusterDrsConfigInfo.enabled = true; var objVcClusterConfigSpecEx; objVcClusterConfigSpecEx = new VcClusterConfigSpecEx(); objVcClusterConfigSpecEx.drsConfig = objVcClusterDrsConfigInfo; objVcClusterConfigSpecEx.groupSpec = arrMyVcClusterGroupSpec; var objVcTask; objVcTask = objVcClusterComputeResource.reconfigureComputeResource_Task(objVcClusterConfigSpecEx, true);