I’m a big advocate of DVS, but licensing is not always available, so for those who use Standard Switches, here’s an error free way of creating Portgroups in all your ESXI hosts.
I say error free because there won’t be any typos as all PGs are created from the same command.
$switchname="myswitch"
$vlanID="100"
get-vmhost | foreach
{
new-VirtualPortGroup -name PG -VirtualSwitch (Get-virtualswitch -VMHost $_ -name $switchname) -VLANÂ $vlanID
}
Just replace the switchname and respective vlanID and you’ll be flying!