Rename VM network adapter automatically from Virtual Machine Manager 2016

Posted by Romain Serre on May 16, 2016
Share on Facebook0Share on Google+0Share on LinkedIn0Share on Reddit0Tweet about this on Twitter0
4.4/5 (5)

The next version of Hyper-V which comes with Windows Server 2016, brings a new feature called Virtual Network Adapter Identification. This feature enables to specify a name when a network adapter is added to the virtual machine and to retrieve this same name inside the VM. This feature can be also managed from Virtual Machine Manager 2016. This feature is really great to automate the renaming of the virtual network adapters inside VMs. In this topic I’ll show you how it is working and how to automate the renaming of the network adapters with PowerShell.

Set Virtual Network Adapter Identification from VMM

When you create a virtual machine from VMM, you have a new setting in the network adapter configuration called Device Properties. You can set the adapter name as the VM Network name or you can specify your own adapter name. In the below example, I have set LAN as adapter name.


When you specify above settings, these settings is enabled from Hyper-V Console perspective :


Once the VM is deployed, you can retrieve the custom adapter name by using Get-NetAdapterAdvancedProperty PowerShell cmdlet.


As you can see in the above screenshot, you can retrieve the custom adapter name in the Hyper-V Network Adapter Name property. So I make a filter on this property by using a pipe.


Then I display only the network adapter name and the custom adapter name. Now we have all the required information to use the Rename-NetAdapter cmdlet.


So I have written a PowerShell script to rename automatically the network adapter name by the Virtual Network Adapter Identification :

When this script is executed, the network adapter name is well renamed.


Rename the VM’s Network Adapter automatically during deployment

To rename the VM’s network adapter during deployment, I add the above script to the sysprep’d image. So first I mount the VHDX as below.


Then I create a folder called Scripts and I paste the script inside the folder. After that I unmount the VHDX.


Next I come back to VMM and I edit my VM template. In OS Configuration I add a GUIRunOnce command to run the RenameNetAdapter.ps1 script.


Next I deploy a new VM. I specify a custom adapter name as below.


Then I add a second network adapter called Cluster. I specify also a custom network adapter.


When the VM is deployed and when you are logged once, the RenameNetAdapter script is executed. So the network adapter should be renamed as below.


Thanks to the next version of Hyper-V and VMM, we can now automate the VM’s network adapters renaming easily 🙂 .

Related materials:


Views All Time
Views Today

Please rate this

To download the software products, please, make your choice below. An installer link and a license key will be sent to the e-mail address you’ve specified. If you consider StarWind Virtual SAN but are uncertain of the version, please check the following document Free vs. Paid. The recent build of Release Notes. A totally unrestricted NFR (Not For Resale) version of StarWind Virtual SAN is available for certain use cases. Learn more details here.

Return to all posts

TBW from SSDs with S.M.A.R.T Values in ESXi
Something to Think About: Nano Server Does Not Support Group Policy
The following two tabs change content below.
Romain Serre
Romain Serre
Senior consultant at Exakis
Romain Serre works in Lyon as a Senior Consultant. He is focused on Microsoft Technology, especially on Hyper-V, System Center, Storage, networking and Cloud OS technology as Microsoft Azure or Azure Stack. He is a MVP and he is certified Microsoft Certified Solution Expert (MCSE Server Infrastructure & Private Cloud), on Hyper-V and on Microsoft Azure (Implementing a Microsoft Azure Solution).