Posted by Simon Long Nov 20, 2009
Adding Virtual PortGroups to all ESX Hosts in a Cluster
Connect-VIServer -Server <vCenter Server>$AllHosts = Get-Cluster <Cluster Name> foreach ($ESXHost in ($AllHosts | Get-VMHost)) { Get-VMHost $ESXHost | Get-VirtualSwitch -Name <vSwitch Number> | New-VirtualPortGroup -Name <Virtual PortGroup Name> -VLanId <VLan ID> } Disconnect-VIServer -Confirm:$false