none
Configuring IP Address by NIC Model. RRS feed

  • Question

  • hi everyone,

    how do i configure an IP address to a specific LAN card, and not by the windows display name? (e.g Ethernet, Ethernet1,etc...)

    I've been trying to find an answer in microsoft power shell documentation by i couldn't find what i needs.

    in the test lab sometime test engineers are "ghosting" the computers (it's the same procedure as formatting them), and instead of letting them configure the IP statically i would like the power shell to do that automatically after ghost.

    in my scenario the test machines are laptops.

    the built in network adapter for the laptop is: INTEL Ethernet controller I217-LM

    the USB to Lan adapter model name is:ASIX AX88179 USB 3.0 gigabit ethernet Adapter.

    I want the power shell to configure the IP address in the ASIX AX88179, and NOT on the Intel adapter how do i tell power shell to do that?


    Wednesday, April 17, 2019 1:45 PM

Answers

  • Have you tried something like this?
    $adapter = Get-NetAdapter | where InterfaceDescription -match 'ASIX'
    if ($adapter -is [Microsoft.Management.Infrastructure.CimInstance]) {
        New-NetIPAddress -InterfaceIndex $adapter.InterfaceIndex -IPAddress 192.0.2.5 -PrefixLength 24 -DefaultGateway 192.0.2.1
    }
    

    • Marked as answer by Nahum Eliash Thursday, April 18, 2019 11:47 AM
    Thursday, April 18, 2019 8:12 AM

All replies

  • A quick search found this:

    https://www.technig.com/configure-ip-address-using-powershell/


    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Wednesday, April 17, 2019 3:05 PM
  • hi Rich,

    first of all thank you for you kind reply... :)

    I've been looking at the link you sent  me and here's a question you might be able to assist me with...

    i understand that i can use the interfaceindex value in order to target the NIC i want, my question is does the network adapter index number changes after i format the machine, or it doesn't?

    Thanks, and have a nice day. :)

    Thursday, April 18, 2019 7:27 AM
  • An index can change on a reinstall if the interface is detected in a different order.  There is no guarantee.

    It is always best to assign IP addresses via DHCP.  Static addresses are legacy and only required when legacy software expects a static IP.   There is no current software that assumes a static address.


    \_(ツ)_/

    Thursday, April 18, 2019 7:32 AM
    Moderator
  • Have you tried something like this?
    $adapter = Get-NetAdapter | where InterfaceDescription -match 'ASIX'
    if ($adapter -is [Microsoft.Management.Infrastructure.CimInstance]) {
        New-NetIPAddress -InterfaceIndex $adapter.InterfaceIndex -IPAddress 192.0.2.5 -PrefixLength 24 -DefaultGateway 192.0.2.1
    }
    

    • Marked as answer by Nahum Eliash Thursday, April 18, 2019 11:47 AM
    Thursday, April 18, 2019 8:12 AM
  • i tested one of the machine with the index cmdlets but unfortunately after ghost/fomrating the machine, the index value change to a different number.

    Thursday, April 18, 2019 11:47 AM
  • Thank you so much!

    works like magic!!! :)

    Thursday, April 18, 2019 11:47 AM
  • You'd get the interfaceindex from the Get-NetAdapter results that you'd run. The index won't change while the script s running. :-)

    --- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)

    Thursday, April 18, 2019 2:52 PM