Add / Remove port groups and VLANs using the ESXi command line

Useful commands for modifying port groups and VLAN settings on ESXi. Can be used in scripts of course to do additions / removals / changes in bulk.

List vSwitches:
=============================================
esxcli network vswitch standard list

List port groups
=============================================
esxcli network vswitch standard portgroup list

Add port group named “VLAN-900” to vSwitch0
=============================================
esxcfg-vswitch --add-pg=VLAN-900 vSwitch0

Assign VLAN 900 to port group “VLAN-900”
=============================================
esxcfg-vswitch -v 900 -p VLAN-900 vSwitch0

Delete port group TEST from vSwitch0
=============================================
esxcfg-vswitch --del-pg=TEST vSwitch0

Leave a Reply