Renaming Network Interfaces (when you have multiple)

You are here:
< Back

This How-To is for when you have a Hyper-V virtual machine that has multiple network interfaces, and you want/need to rename them to something that’s more relevant to their purpose. For instance, if you are running a virtual firewall, then you’ll at least have two interfaces.  One being used for the WAN connection, and the other for a LAN connection.  When you add them using the GUI interface, they’ll both be named “Network Adapter” like you see in the two examples below:

With both of them named the same exact thing, it’s very hard to make changes to just one of them in the PowerShell command line (CLI).  So in order to rename them, here’s what you need to do.

For reference purposes, the name of our VM in this tutorial is “Test VM” (without the quotes).  Please replace all references to “Test VM” with the full name of your VM.

First, you need to open up a PowerShell prompt.

Second, you need to execute the following command to list out the interfaces your VM currently has. (Mostly just so you can see the before and after)

This will give you output like this:

Again, you can see both interfaces are named the exact same thing.

Next, you need to execute this:

This puts each adapter into an array. Next, you can execute this to see what I mean.

And it’ll just return the value of the first entry from above, like so:

Now for the fun part. To rename them, all you now need to do is this:

And now you can re-list them on the screen to see the final results:

And here’s the results:

And to see it all together in the CLI:

All done!