VMware Cloud Community
drwoodberry
Contributor
Contributor
Jump to solution

Adding Second NIC to vSwitch

I am working on trying to add a second physical network adapter to the vswitch that is setup by default during ESXi install. I am using the below code, but when I execute it, it actually disconnects the main physical nic and of course I then lose connection. I tried different varients of this, and even ended up adding a vmk port which I did not want to do. I just want to add the second nic as a standby nic.

#Add second NIC to the virtual switch
$nic = Get-VirtualSwitch -VMHost $currentHost -Name "vSwitch0"
Set-VirtualSwitch -VirtualSwitch $nic -Nic vmnic1

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership
Jump to solution

The Set-VirtualSwitch cmdlet accepts an array of strings as the value of the -Nic parameter. So you should be able to do:

#Add second NIC to the virtual switch
$nic = Get-VirtualSwitch -VMHost $currentHost -Name "vSwitch0"
Set-VirtualSwitch -VirtualSwitch $nic -Nic vmnic1,vmnic2

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Afaik, you have to specify all the NICs.

As in Set-VirtualSwitch it says that the NICs will "replace" the old ones.

____________

Blog: LucD notes

Twitter: lucd22


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

RvdNieuwendijk
Leadership
Leadership
Jump to solution

The Set-VirtualSwitch cmdlet accepts an array of strings as the value of the -Nic parameter. So you should be able to do:

#Add second NIC to the virtual switch
$nic = Get-VirtualSwitch -VMHost $currentHost -Name "vSwitch0"
Set-VirtualSwitch -VirtualSwitch $nic -Nic vmnic1,vmnic2

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
drwoodberry
Contributor
Contributor
Jump to solution

Thanks so much, I overread the replace all NIC part. The above code works, but it still loses connectivity to the host. Is there anyway to maintain that connectivity and add the nic. I had to go to the host manually and restart the management agents and management network for it to show back up. When you do this through virtual center, you never lose connectivity. Anyway to code it like it would be done in VC without disconnecting?

Thanks again.

0 Kudos