Using PowerCLI to change all LUNs to Round Robin

Each week I learn a little more about PowerShell and PowerCLI. Today, I wanted to share how I used PowerCLI to change all of the LUNs connected to my ESXi hosts to the Round Robin multipathing policy.

Note: Please make sure that your SAN/storage supports Round Robin before making these changes.

First thing you need to do is open PowerCLI (download) and connect to your vCenter server:

Connect-VIServer vcenter.domain.local

Next, run this command to see a list of all of your LUNs and their current MultipathPolicy:

Get-Vmhost | Get-Scsilun

If you want to filter down the list to just the LUNs that are currently not configured with the Round Robin Multipaty Policy, add a -notlike Where clause:

Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"}

Your results mike look something like this:

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame
---------- -----------------              -------         ---------- ---------------
naa.600... /vmfs/devices/disks/naa.600... disk             1,673.584 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk                 0.020 MostRecentlyUsed
naa.600... /vmfs/devices/disks/naa.600... disk               500.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               500.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               800.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk                67.055 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk                 0.020 MostRecentlyUsed
naa.600... /vmfs/devices/disks/naa.600... disk               800.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk                67.055 Fixed

Notice that some of the included disks appear to be the directed attached volumes on my ESXi host (the ones that are 67 GB in size, and that really small 20 MB disk). Since I don’t know for sure what these disk are or if they support RoundRobin, I want to exclude them too. I’ll do so by adding another Where clause that selects disks with a CapacityGB greater than or equal to 100 GB:

Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 100}

Perfect. My newly filtered results look this this:

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame
---------- -----------------              -------         ---------- ---------------
naa.600... /vmfs/devices/disks/naa.600... disk             1,673.584 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               500.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               500.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               800.000 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk               800.000 Fixed

I’m now ready to change these five LUNs to the RoundRobin MultiPathPolicy and can do this with the Set-Scsilun command like so:

Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 100} | Set-Scsilun -MultiPathPolicy RoundRobin

A few minutes later and all of my LUNs are now configured to use Round Robin. I was able to make this change on production systems, without going into maintenance mode, and without a disruption in service.

1 Comment


  1. Nice to see another PowerCLI blogger appear. Nice article, and I hope to see many more PowerCLI related posts in the future.

Comments are closed.