To use this examples, there requirements are: VMware PowerCLI and a VMWare vCenter.
This example will copy all vlan’s (Virtualportgroup) from one host to another.
It will take all vlan’s from vSwitch0 on the old host, and copy it to the new host on vSwitch1.
connect-viserver $oldhost = get-vmhost -name OldServerIP $newhost = get-vmhost -name NewServerIP $oldhost | get-virtualswitch -name vSwitch0 | get-virtualportgroup | foreach { $newportgroup = $newhost | get-virtualswitch -name vSwitch1 | new-virtualportgroup -name $_.Name -VLanID $_.VLanID }