by lunarg on May 8th 2017, at 14:32

A very common practice when setting up SAN storage on a VMWare cluster is to configure the storage path policy to be set to "Round Robin" to properly benefit from MPIO in addition to standard failover. However, if the cluster consists of many nodes or there are many volumes, this can take up quite a lot of time if you configure this using the (Web)GUI. A better way to adjust the setting for the entire cluster is through PowerCLI.

The one-liner:

Get-VMHost <Cluster-or-Host> | Get-ScsiLun -LunType "disk" | Where {$_.MultipathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin

The cmdlet selects a cluster or host, gets all LUNs which are of type disk (so, volumes) where the PSP has not been set to "Round Robin". On the resulting LUNs, the policy is then set to "Round Robin".

There are many variants possible with the cmdlet. You can target a single host, a set of hosts or the entire cluster by changing the name in Get-VMHost. A simple use case would be if a new ESXi host was added to the cluster and the volumes added still have the "MRU" policy enabled.

Another method to limit the policy configuration to a certain type of HBA (e.g. FC), you can do something like:

Get-VMHost | Get-VMHostHba -Type "FibreChannel" | Get-ScsiLun -LunType "disk" | where {$_.MultipathPolicy -ne "RoundRobin"} | Set-ScsiLun -MultipathPolicy RoundRobin

Other variations are possible as well, of course.

Before actually running the Set-ScsiLun portion, it is a good idea to doublecheck what will happen when running the one-liner by leaving the Set-ScsiLun part out. A list of volumes will be displayed, allowing you to verify which volumes will be changed.