How can i create virtual iSCSI controller with hyper-v wmi api? RRS feed

  • Question

  • Hello,

    Can anyone help me with creating virtual iSCSI controller and assigning it to virtual machine using WMI? I need it because I want to create virtual machine with controller attached to it. As far as I can understand this issue i need to create iscsi setting data, but I can't find any reference on which wmi class to use? This is what I am trying to do and It's not working :

    ManagementClass scsiClass =
       new ManagementClass(@"root\virtualization\v2:Msvm_SCSIProtocolController");
    ManagementObject scsiData = scsiClass.CreateInstance();
    string[] resourceSettings = new string[3];
    // Memory settings.
    resourceSettings[0] = memorySettingData.GetText(TextFormat.CimDtd20);
    // Processor settings. 
     resourceSettings[1] = processorSettingData.GetText(TextFormat.CimDtd20);
    // Add SCSI
     resourceSettings[2] = scsiData.GetText(TextFormat.CimDtd20);

    If I remove "scsiData" then virtual machine creates successfully, any help please?

    Documentation :  https://docs.microsoft.com/en-us/windows/desktop/hyperv_v2/windows-virtualization-portal

    Edit : I need to use C#, powershell is not an option.
    Thursday, March 14, 2019 7:51 PM


All replies