VMware Cloud Community
f10
Expert
Expert
Jump to solution

Cannot Add and Remove Network Cards from an existing virtual switch.

Hi,

I am trying to add network cards to an existing virtual switch, in my case I have vSwitch2 connected to vmnic3 and I want to add vmnic4. If I use the command below it replaces vmnic3 with vmnic4

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic4

I have checked the manual and the description for nic parameter is "Specify new network interface cards for the virtual switch. The old NICs are replaced by the specified ones."

I am using VMware vSphere PowerCLI 4.1 build 264274, please help me with the correct comdlets to ADD and REMOVE network cards from an existing virtual switch.

Thanks in advance.

f10

VCP3, VCP4, HPCP, HP UX CSA

Regards, Arun Pandey VCP 3,4,5 | VCAP-DCA | NCDA | HPUX-CSA | http://highoncloud.blogspot.in/ If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
1 Solution

Accepted Solutions
schepp
Leadership
Leadership
Jump to solution

Hi,

if you want to keep the old nic on that vswitch you can use the following syntax:

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic3,vmnic4

Removing vmnic4 again would be your old cmd

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic3

because the existing NICs on that vswitch are replaced like you read in the documentary.

Regards.

View solution in original post

0 Kudos
4 Replies
schepp
Leadership
Leadership
Jump to solution

Hi,

if you want to keep the old nic on that vswitch you can use the following syntax:

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic3,vmnic4

Removing vmnic4 again would be your old cmd

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic3

because the existing NICs on that vswitch are replaced like you read in the documentary.

Regards.

0 Kudos
f10
Expert
Expert
Jump to solution

Thank you for the update.

This solves my problem of adding the network card.

Could you also provide the cmdlets to remove a network card from an existing vSwitch.

Regards, Arun Pandey VCP 3,4,5 | VCAP-DCA | NCDA | HPUX-CSA | http://highoncloud.blogspot.in/ If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
schepp
Leadership
Leadership
Jump to solution

Maybe my edit of my above answer was too late:

If you got vmnic3 and vmnic4 on that switch now and you want to remove vmnic4

just do a

Set-VirtualSwitch -VirtualSwitch $vswitch -Nic vmnic3

it will replace the old nics (vmnic3 and vmnic4) with the new one (vmnic3).

Little bit strange, but it works Smiley Wink

Regards

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That solution is correct, but if you want to automate this you could also do something like this

$NicToBeRemoved = "vmnic3"

Get-VMHost | Get-VirtualSwitch | where {$_.Nic -contains $NicToBeRemoved} | %{
	$newNics = $_.Nic | where {$_ -ne $NicToBeRemoved}
	$_ | Set-VirtualSwitch -Nic $newNics
}

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos