vSphere 4.1 – Changing Path Selection Policy in Bulk

If you are like me, you will have come across the requirement to change the Path Selection Policy in vSphere.  For most people this is performed from the vSphere Client and requires you to select each lun for each datastore on each host and change the Path Selection Policy to either Fixed, Most Recently Used or Round Robin.
This is fine to do through the GUI for a single datastore across only a couple of hosts but recently I had to go through and do this for over 30 datastores across at least 10 hosts… performing this task through the GUI method would have taken me a good couple of hours to complete.

We had recently performed a firmware upgrade to our XIV Gen 2 unit which therefore allowed us to begin to take advantage of the VAAI features in vSphere (more information on this will follow).  On our previous XIV firmware version, we were advised to have our Path Selection Policy configured for Fixed but under the new version, the advice was to switch over to the preferred method of Round Robin.

I therefore performed a quick google and came across the article by the ‘VirtualServerGuy’ (http://www.virtualserverguy.com/blog/2010/9/22/modify-vsphere-path-selection-policy-in-bulk.html) which explained how to perform this task in a simpler way.

The details below are taken from that guide:
Start up the vSphere PowerCli – we have this installed on our vCenter server as we have scripts running to check for snapshots and path failures.

1.  Connect to your vCenter Server:
                     Connect-VIServer <vCenterServerName>

2.  List all of the hosts and disks that are on the XiV array that are not set for RoundRobin:

Get-VMHost | Get-ScsiLun -LunType “disk” | where {$_.MultipathPolicy –ne “RoundRobin” -and $_.model -like “*xiv*”}| format-table VMHost,CanonicalName,MultiPathPolicy –autosize
Here is some more information on this one-liner:
  • Get-VMHost – connects to each host under management by the vCenter server
  • Get-ScsiLun – gets SCSI LUNs of type “disk” (as opposed to a controller or something else) that have a MultiPath Policy that is not Round Robin and also have a model name that includes “XIV” in the name.
  • format-table – dumps a table listing the ESX host, the name of the LUN, and the current policy to the screen

The key thing now is to go through and change all of the Luns identified in one go, so instead of dumping a table to the screen, let’s pipe the results to the command Set-ScsiLun -MultipathPolicy “RoundRobin” .

The complete command is:

Get-VMHost | Get-ScsiLun -LunType “disk” | where {$_.MultipathPolicy –ne “RoundRobin” -and $_.model -like “*xiv*”}| Set-ScsiLun -MultipathPolicy “RoundRobin”

If you want to run the command first to verify that it will do what you expect it to do, then add the -whatif entry to the end of the line.  Once you are satisfied, remove the -whatif entry and the command will then make the changes.

I believe that this method went through and performed the change to all of my hosts and all of the relevant Luns in around 10 minutes automatically instead of me spending around two hours manually performing the same task.

About the Author


I have been in IT for the past 15 years and using virtualisation technologies for around the past 8 years. I started, as quite a lot of people do, working with PCs after playing with such iconic systems like the ZX81, ZX Spectrum and then progressing through 386s, 486s, Pentiums etc. After being headhunted at sixth form to work for a small company based around Hertfordshire, UK. I began working with small businesses and gaining a lot of hardware experience. Three years later, after helping to increase the size of the business, I needed to gain exposure to a larger environment to progress my own career. I joined a large manufacturing company around Electronic Test and Measurement which progressed my skills onto more PC work, hardware work and then onto Server Operating Systems. I progressed again onto a consultancy company based in Reading, UK. Initially working as an engineer performing hardware / software installations for larger companies contracted out to the consultancy company, I moved up into a Consultant position continuing my travel across the UK assisting and providing solutions to companies. I finally moved on again to my current position, working back in Hertfordshire, UK. Again working for a large manufacturing company, this time with over 50,000 users worldwide. I am responsible for the datacenter hardware, the storage environment, the vmware environment and also implementing their new Citrix XenApp farm. My days are busy but also productive, its a friendly environment and in my four years of being with the company, I have seen many changes in technology and infrastructure in use within the company. About the site I started this site as I had been thinking of having more of a presence on the web for a while. On a daily basis, I perform tasks and use tools that others may not use or may not think to do and therefore I thought that I would share some of these experiences and tips with others to help with their day to day work. Currently, my main focus of work is around VMware and Veeam Backup & Replication but hopefully as my tasks progress, I’ll be able to share useful bits of information about other areas of IT as well.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.