none
Rename virtual machine network adapter with identical name

    Question

  • My Virtual machine hosted on Windows 2012 Hyper V have 2 network cards :

    Name            IsManagementOs               VMName     SwitchName      
    ----            -------------- ------               ----------       ----------  
    Network Adapter False                             VM1            LAN1
    Network Adapter False                             VM1            LAN2

    I would like to rename one of the network card to be able to assign to one of the network card a VirtualSubnetID.

    The Rename-VMNetworkAdapter command don't made the difference with my 2 cards because they have the same name :

    Rename-VMNetworkAdapter -name "Network Adapter" -vmname "VM1" -NewName "Network Adapter 2 "-id "Private Mutualia" -vmname "ff1.cesia.fr" -NewName "Private Mutualia2"

    How can i rename only one network adapter ?

    Tks for your help !

    Tuesday, February 12, 2013 11:48 PM

Answers

  • Actually, Hyper-V VMs can have up to 12 NICs, but that is not pertinent.

    You can rename based upon MAC address.  Below is a segment of PowerShell code where I am passing in a table with desired name ($ucsa.name) and MAC address ($ucsa.addr).  I match the MAC address and then rename to the matching name.  I also have passed in the name of the server I want to work on ($srvr)/

    ForEach ($UcsA in $UcsAdapters) {
        $NICindex = (Get-WMIobject Win32_NetworkAdapterConfiguration -namespace "root\CIMV2" -computername $Srvr | Where-Object {$_.MACaddress -eq $UcsA.Addr}).Index
        $NIC = (Get-WMIobject Win32_NetworkAdapter -computername $Srvr | Where-Object {$_.Index -eq $NICindex})
        If ($NIC.NetconnectionID -ne $UcsA.name) {
            $NIC.NetconnectionID=$UcsA.name
            $NIC.Put()
        }
    }
    


    .:|:.:|:. tim

    Wednesday, February 13, 2013 1:36 PM

All replies

  • Hi,

    What’s the OS version of your Virtual Machine? Is the Virtual Machine installed with a Server Core Edition?

    Can you modify the virtual machine adapter name through user interface?

    If these virtual adapters have same name, network adapter rename operation apply to the two Virtual adapters. In my opinion, I think network adapter has same name is not allowed, so maybe there is something wrong. You may remove one Virtual network adapter, and then rename the rest one. After that, add a new virtual network adapter and rename it.

    For more information please refer to following MS articles:

    Rename-VMNetworkAdapter
    http://technet.microsoft.com/en-us/library/hh848517.aspx
    Remove-VMNetworkAdapter
    http://technet.microsoft.com/en-us/library/hh848565.aspx
    Add-VMNetworkAdapter
    http://technet.microsoft.com/en-us/library/hh848564.aspx


    Lawrence

    TechNet Community Support

    Wednesday, February 13, 2013 7:03 AM
  • My vm is a windows 2008 r2. Hyper-v is installed with the graphical interface. There is no way to rename a hyper-v network adapter with the graphical interface. I don't want to rename the network card inside the vm but only the name displayed on hyper-v. Network adapter with the same name are allowed. You can add with hyper-v 10 network cards, the 10 network card will have the same name but a different guid. There is no way to rename identical network adapter with rename-vmnetwork adapter. I can't uninstall my network card in my vm because its a forefront tmg with many network card.
    Wednesday, February 13, 2013 10:26 AM
  • Actually, Hyper-V VMs can have up to 12 NICs, but that is not pertinent.

    You can rename based upon MAC address.  Below is a segment of PowerShell code where I am passing in a table with desired name ($ucsa.name) and MAC address ($ucsa.addr).  I match the MAC address and then rename to the matching name.  I also have passed in the name of the server I want to work on ($srvr)/

    ForEach ($UcsA in $UcsAdapters) {
        $NICindex = (Get-WMIobject Win32_NetworkAdapterConfiguration -namespace "root\CIMV2" -computername $Srvr | Where-Object {$_.MACaddress -eq $UcsA.Addr}).Index
        $NIC = (Get-WMIobject Win32_NetworkAdapter -computername $Srvr | Where-Object {$_.Index -eq $NICindex})
        If ($NIC.NetconnectionID -ne $UcsA.name) {
            $NIC.NetconnectionID=$UcsA.name
            $NIC.Put()
        }
    }
    


    .:|:.:|:. tim

    Wednesday, February 13, 2013 1:36 PM
  • Hi Guy.

    you may try use this:

    PS C:\> Get-VMNetworkAdapter -VMName w2k3homologa

    Name          IsManagementOs VMName       SwitchName MacAddress   Status IPAddresses
    ----          -------------- ------       ---------- ----------   ------ -----------
    ExternalAdapt False          w2k3homologa External   00155D19E222        {}
    InternalAdapt False          w2k3homologa internal   000000000000        {}


    PS C:\> $VMNetAdap = Get-VMNetworkAdapter -VMName w2k3homologa
    PS C:\> $VMNetAdap[0]

    Name          IsManagementOs VMName       SwitchName MacAddress   Status IPAddresses
    ----          -------------- ------       ---------- ----------   ------ -----------
    ExternalAdapt False          w2k3homologa External   00155D19E222        {}


    PS C:\> $VMNetAdap[1]

    Name          IsManagementOs VMName       SwitchName MacAddress   Status IPAddresses
    ----          -------------- ------       ---------- ----------   ------ -----------
    InternalAdapt False          w2k3homologa internal   000000000000        {}


    PS C:\> rename-VMNetworkAdapter -VMNetworkAdapter $VMNetAdap[0] -newname ExternalNic
    PS C:\> rename-VMNetworkAdapter -VMNetworkAdapter $VMNetAdap[1] -newname InternalNic
    PS C:\> Get-VMNetworkAdapter -VMName w2k3homologa

    Name        IsManagementOs VMName       SwitchName MacAddress   Status IPAddresses
    ----        -------------- ------       ---------- ----------   ------ -----------
    ExternalNic False          w2k3homologa External   00155D19E222        {}
    InternalNic False          w2k3homologa internal   000000000000        {}


    PS C:\>

     


    Eroi

    Wednesday, October 09, 2013 2:57 PM