Add Port Group and VLAN to ESX vSwitch via PowerCLI

get-vmhost -name <name as shown in vSphere client> | Get-VirtualSwitch -name <name of vSwitch> | new-VirtualPortGroup -name "<name to call port group>" -vlanid <numeric VLAN ID>

Note that the quotes around the port group name are only necessary if the name contains a space.

e.g.
get-vmhost -name esxhost1.rcmtech.co.uk | Get-VirtualSwitch -name vSwitch1 | new-VirtualPortGroup -name "192.168.10.x subnet" -vlanid 10

This entry was posted in PowerShell, vSphere. Bookmark the permalink.

One Response to Add Port Group and VLAN to ESX vSwitch via PowerCLI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s