Hi,
Someone asked today how to reconfigure all virtual switches to use IP-based load balancing. I decided to post the answer here, hope you find it useful.
Someone asked today how to reconfigure all virtual switches to use IP-based load balancing. I decided to post the answer here, hope you find it useful.
# This script will reconfigure all virtual switches with more than 1 NIC to use
# IP-based load balancing.
# NOTE: The script will reconfigure *ALL* virtual switches on *ALL* hosts.
# Change the Get-VMHost statement if that's not what you want.
Get-VMHost | Get-VMHostNetwork | foreach {
$networkView = $_ | Get-View
$switches = $networkView.NetworkInfo.Vswitch | Where { $_.Pnic.length -gt 1 }
foreach ($switch in $switches) {
$spec = $switch.spec
$spec.policy.nicTeaming.policy = "loadbalance_ip"
# Other values are loadbalance_srcmac, loadbalance_srcid (The default), failover_explicit
$networkView.UpdateVirtualSwitch($switch.Name, $spec)
}
}