VMware Cloud Community
StephVP
Contributor
Contributor

Change NIC label in Windows via PowerCLI

     Hello,

I can create VMs with multiple NICs via PowerCLI but I cannot change their NIC label on Windows (I can but names are setted randomly).

Example: a VM is created with a 3 NICs setting (back, front, admin). I want NICs to be named "BACK", "FRONT" and "ADMIN"

but network cards are named by default "Local Area Connection", "Local Area Connection 2" and "Local Area Connection 3".

If I add netsh commands in the Runonce part of a customization to rename them:

$item.Spec.identity.guiRunOnce = New-Object VMware.Vim.CustomizationGuiRunOnce
$item.Spec.identity.guiRunOnce.commandlist = "netsh interface set interface name=""Local Area Connection"" newname=$label1", "netsh interface set interface name=""Local Area Connection 2"" newname=$label2","netsh interface set interface name=""Local Area Connection 3"" newname=$label3"


cards are named randomly "FRONT", "ADMIN" and "BACK" because there is no link between WMWare NICs IDs and Windows NICs IDs

(for example, the front NIC is named "BACK", the admin NIC is named "FRONT", and the back NIC is named "ADMIN").

Does anyone know a way to rename them properly ?

0 Kudos
2 Replies
LucD
Leadership
Leadership

Do the portgroups to which you connect the vNICs use VLANIDs ?

If yes, you can use the Get-NetAdapter cmdlet in the Windows OS to retrieve the VLANIDs and based on that assign the correct NIC names inside the Windows OS.

You could also use the MAC address of the NICs to map them correctly.

You will have to do this after the guest OS is deployed. Something for Invoke-VMScript.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
StephVP
Contributor
Contributor

Thanks for the answer, LucD.

About VLAN IDs, we use them only for trunking, so not systematically.

I thought like you to combine MAC address and Invoke-VMScript commands.

But the thing is I would like to do all configuration in a time.

If there is no other way then I have no other choice.

There is a "dirty" solution.

For a given template, the NICs will be always assigned in the same order.

So you only have to match NICs and labels.

For example, NIC #1 will be for label #2, NIC #3 for label #1, ...

But I think that if you use another template, this random order will change.

I will do some more tests and let you know.

0 Kudos