Inputs:-
workflowVM :- VC:VirtualMachine
// Here we are removing the Hard disk 2
var devices = workflowVM.config.hardware.device;
var disks = new Array();
var configSpec = new VcVirtualMachineConfigSpec();
var deviceConfigSpecs = new Array();
var deviceConfigSpec = new VcVirtualDeviceConfigSpec();
for (i in devices) {
if (devices[i].DeviceInfo.Label.indexOf('Hard disk') >= 0) {
if (devices[i].DeviceInfo.Label == "Hard disk 2") {
System.log(devices[i].DeviceInfo.Label)
System.log(devices[i].capacityInKB / 1024 / 1024)
if (devices[i].capacityInKB / 1024 / 1024 == "10") {
System.log(devices[i].capacityInKB / 1024 / 1024)
deviceConfigSpec.device = devices[i];
deviceConfigSpec.operation = VcVirtualDeviceConfigSpecOperation.remove;
deviceConfigSpecs.push(deviceConfigSpec);
configSpec.deviceChange = deviceConfigSpecs
}
}
}
workflowVM.reconfigVM_Task(configSpec);
}