Setting network configuration on Hyper-V Linux Guest VM using WMI - SetGuestNetworkAdapterConfiguration RRS feed

  • Question

  • Hi, 

    I am trying to set network configuration like IP address, DNS, Gateway, address policy (dhcp/static), etc. on the Hyper-V Linux guest VMs using SetGuestNetworkAdapterConfiguration API in WMI through powershell. I need some information on this API.

    1. Sometimes, the call is returning asynchronously and sometimes the operation is done synchronously. Why is this happening when the parameters are the same? 

    2. When call is returning asynchronously, when retrieving the job object from the return variable is resulting in following error: 

    $ret = $Service.SetGuestNetworkAdapterConfiguration($vm, $networkSettings[0].GetText(1))

    $jobInstance = [WMI]$ret.job

    Cannot convert value "\\HYPER-VHOST6\root\virtualization\v2:Msvm_ConcreteJob.InstanceID="8273DB55-AF16-4264-912C-FBF321AA1664"" to type "System.Management.ManagementObject". Error: "The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"

    Am I missing something here? 

    3. Is there any limitation using this WMI API for setting network configuration on Linux guest VMs, since I am running into these issue intermittently in Linux VMs? 

    I would appreciate any pointers for these queries. 




    Monday, March 4, 2019 6:10 AM


All replies

  • Hi Priya,

    Can give you only a pointer to the automation we use to verify the IP injection, and I don't recall seeing this failure.

    Maybe you can find it useful to compare the code or use this one and see if you run into the same issue?

    Here's the script:


    • Marked as answer by SPriyaM Wednesday, March 27, 2019 10:32 AM
    Monday, March 11, 2019 7:19 AM
  • Hi, 

    My apologies for the delayed response. 

    Thank you very much for providing the reference. 

    Link was very helpful and I was able to retrieve job object correctly. 




    Wednesday, March 27, 2019 10:32 AM