Using PowerCLI to add networks to VMware hosts

Using PowerCLI to add networks to VMware hosts

Using PowerCLI to add networks to VMware hosts

The administrative task of adding a new network to all hosts in a VMware Cluster using vSphere GUI increases as the number of hosts increases. Using PowerCLI, however, the workload is the same for configuring 2 or 200 hosts in a cluster.

The following few commands will add a new portgroup to an existing standard vSwitch on all hosts in a cluster.

foreach ($vmhost in (Get-VMHost -Location "[CLUSTERNAME]" )) {
$vswitch = Get-VirtualSwitch -VMHost $vmhost -Name [VSWITCHNAME] ;
New-VirtualPortGroup -VirtualSwitch $vswitch -Name [NETWORKNAME] -VLanID [VLANID]
}

Get vSphere PowerCLI 5.5 here: https://my.vmware.com/web/vmware/details?downloadGroup=PCLI550&productId=352