Thank you very much for your help. I am trying to adapt my code to resemble yours in the hope of being able to do this, but in the vSphere client, I see this error: Invalid configuration for device '1'. This is the code I am using (PHP):
$folders = $vhost->findAllManagedObjects('Folder', array());
//print_r($folders[0]);
$controller = new stdClass();
$controller->device = new stdClass();
$controller->device->type = "VirtualLsiLogicController";
$controller->device->busNumber = 12;
$controller->device->key = -2;
$controller->operation = "add";
$deviceChange = new stdClass();
$device = new stdClass();
$config = new stdClass();
$backing = new stdClass();
$files = new stdClass();
$config->name = 'APITestVM';
$config->memoryMB = 2048;
$config->deviceChange = array($controller, $deviceChange);
$config->key = '';
$config->files = $files;
$files->vmPathName = "[test]";
$deviceChange->device = $device;
$deviceChange->fileOperation = 'replace';
$deviceChange->operation = 'add';
$device->backing = $backing;
$device->key = -102;
$device->busNumber = 12;
//$device->unitNumber = 1;
$device->controllerKey = -2;
$backing->compatibilityMode = 'virtualMode';
$backing->deviceName = 'vmhba37';
$backing->lunUuid = '01000000006234396630366330303735383361636564323465383638613836396534333331564952545541';
$folders[0]->CreateVM_Task(array(
'config' => $config,
'pool' => array("_" => "ha-root-pool", "type" => "ResourcePool")
));
Can you please take a look and see if anything sticks out to you as being incorrect? Thanks again.