IPAddress sequence not maintained (Win32_NetworkAdapterConfiguration) RRS feed

  • General discussion

  • I am using this WMI call in powershell script.

    Get-WmiObject Win32_NetworkAdapterConfiguration 

    In the result IPAddress array doesn't retain IP sequence.

    For example, the primary IP is 192.x.y.z1 and other ip is 192.x.y.z2 (for the same interface).

    In the result of above call, it returns {192.x.y.z2, 192.x.y.z1}. I am facing issue when calling EnableStatic() with this array. As a result, IP sequence changes to 192.x.y.z2 becoming primary IP and 192.x.y.z1 becoming secondary

    > Get-WmiObject Win32_NetworkAdapterConfiguration 

    DHCPEnabled      : False
    IPAddress        : {192.x.y.z2, 192.x.y.z1}
    DefaultIPGateway : {192.x.y.1}

    From registry:

    IPAddress REG_MULTI_SZ 192.x.y.z1 192.x.y.z2

    Any help here to get correct sequence from WMI call? 


    • Edited by aksrivastav Monday, October 10, 2016 9:17 AM
    • Changed type Bill_Stewart Monday, November 21, 2016 7:29 PM
    Monday, October 10, 2016 9:15 AM

All replies

  • Can't tell what you are doing because the code you posted is not capable of changing any IP addresses.  It can only return all configurations as-is.


    Monday, October 10, 2016 12:29 PM
  • EnableStatic stores the IPs in the order you provide. The network UI reflects this, however when querying the network adapters with Get-WmiObject you get back the IPs in the opposite order. Came across the same issue then working on AutomatedLab.

    However, I am not sure if the order of the IPs does matter at all. The order of the network adapters can be quite important tough.


    Monday, October 10, 2016 2:08 PM
  • Yes. That is what the issue is. But i think i figured out that it's SkipAsSource flag which can be used to make the IP matter. And true, network binding is what matters more.

    Thanks a lot. 

    Monday, October 10, 2016 5:27 PM