Adding and Deleting Virtual Switches with ESXCLI

You can add and delete virtual switches by using the esxcli network vswitch standard namespace.

Specify one of the options listed in Connection Options for ESXCLI Host Management Commands in place of <conn_options>.

  • Add a virtual switch.
    esxcli <conn_options> network vswitch standard add --vswitch-name=vSwitch42
    You can specify the number of port groups while adding the virtual switch. If you do not specify a value, the default value is used. The system-wide port count cannot be greater than 4096.
    esxcli <conn_options> network vswitch standard add --vswitch-name=vSwitch42 --ports=8
    After you have added a virtual switch, you can set switch attributes. See Setting Switch Attributes with ESXCLI. You can also add one or more uplink adapters. See Linking and Unlinking Uplink Adapters with ESXCLI.
  • Delete a virtual switch.
    esxcli <conn_options> network vswitch standard remove --vswitch-name=vSwitch42
    You cannot delete a virtual switch if any ports on the switch are still in use by VMkernel networks or virtual machines. Run esxcli network vswitch standard list to determine whether a virtual switch is in use.