Change vSphere path policy to "Round Robin" via PowerCLI

A very common task we get during trainings as well as consulting/troubleshooting jobs is the request to automatically set all storage path policies to for example "Round Robin"

Normally you need to touch each host and volume, which can be pretty annoying, especially if you have more 8 or more hosts with each 5 or more LUNs allocated.

Step by step approach on how to address this with PowerCLI.

1) The object we are looking into is the ScsiLun which can be queried with the Get-ScsiLun command. The Get-ScsiLun command needs a host as a parameter, so the first run would be:

Get-VMHost -Location <Cluster>|Get-ScsiLun -LunType "disk"

You simply replace <Cluster> with your cluster name, so for example in our lab I run:

Get-VMHost -Location "FES74-LAB"|Get-ScsiLun - LunType "disk"

2) As this command should keep a low load on our environment we are only interested in those LUNs where the path policy is not equal "RoundRobin"

So our next command will be:

Get-VMHost -Location <Cluster>|Get-ScsiLun -LunType "disk"|where {$_.MultipathPolicy -ne "RoundRobin"}

If all LUNs are setup already in RoundRobin mode we have nothing to be done left. In the next step we combine this command with one to set the Policy.

3) To set/reset the policy you need to append the Set-ScsiLun command:

Final command would be:

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


As you can see from the above PowerCLI is not as complex as many people think and this one line command has saved me already hours of time in setting up path policies.

Nice quick time saver! I recommend adding in Get-VMHostHba -Type "FibreChannel" so you don't try and change the policy on other types of LUNs

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


Go back