You must add a synthetic disk (ResourceType. Disk , ResourceSubType. DiskSynthetic ) using Msvm_VirtualSystemManagementService.AddVirtualSystemResources. Parent = WMI path of the SCSI controller.
ManagementObject synthetic = Utilities.GetResourceAllocationSettingData(scope, ResourceType.Disk, ResourceSubType.DiskSynthetic); synthetic["Parent"] = <ideControllerPath>; //or SCSI controller path (WMI path) synthetic["Address"] = <diskDriveAddress>; //0 or 1 for IDE string[] RASDs = new string[1]; RASDs[0] = synthetic.GetText(TextFormat.CimDtd20);
Then attach the virtual hard drive (ResourceType. StorageExtent , ResourceSubType. VHD ) using Msvm_VirtualSystemManagementService.AddVirtualSystemResources. Parent = WMI path to the synthetic disk, Connection = * .vhd file path.
ManagementObject hardDisk = Utilities.GetResourceAllocationSettingData(scope, ResourceType.StorageExtent, ResourceSubType.VHD); hardDisk["Parent"] = <syntheticPath>; //WMI path string[] connection = { <vhdPath> }; //Path to *.vhd file hardDisk["Connection"] = connection; string[] RASDs = new string[1]; RASDs[0] = hardDisk.GetText(TextFormat.CimDtd20);
Use Common Utilities for Virtualization Samples and WMI Explorer .
source share