Use PowerShell to change the VMWare Path Selection Policy for a LUN

I got this information from Arnim Van Lieshout’s blog, and it turned out to be incredibly useful.  I found myself in a position where I needed to be able to change the path selection policy for all of our HP EVA datastores to use round-robin instead of most-recently-used as the Path Selection Policy.  Here’s how I did it:

Connect to the host server in question:

connect-viserver host.sweeneops.lab

Create the ESXCLI PowerShell object:

$esxcli = get-esxcli

I happen to know that all my EVA devices are named naa.6005************.  I don’t know if that is universal, but that’s how it is in my environment.  With that said, I then enumerate all the devices by filtering the results based on the device, and then further filter based on PSP type (just in case someone has purposely set one to something else:

$esxcli.nmp.device.list() | ?{$_.device -like "naa.6005*"} | ?{$_.PathSelectionPolicy -eq "VMW_PSP_MRU”} | ft DeviceDisplayName, pathselectionpolicy -auto

The results all look correct, so I move on to actually make the change:

$esxcli.nmp.device.list() | ?{$_.device -like "naa.6005*"} | ?{$_.PathSelectionPolicy -eq "VMW_PSP_MRU"} | %{$esxcli.nmp.device.setpolicy($null, $_.device, "VMW_PSP_RR")}

I was so shocked by how quickly it ran, as opposed to the slow GUI performance, that at first I thought I must have made a mistake.  After further inspection, however, I found that it’s just much much faster to to do it this way than to use the GUI.

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: