Tag Archive for set mulitpathing policy with powercli

Set Datastore Multipathing Policy Automaticly with PowerCLI

You may find when you add a new host to your vSphere environment and discover any datastores presented to the host, the multipathing policy will be automatically set to MRU (Most Recently Used). For best performance it’s recommended to change this policy to Roundrobin, however this is a very manual and tedious task of adjusting each datastore on each host.

To speed this process up, below you can find a PowerCLI command that will set all datastores on a specific host to Roundrobin.

Get-Cluster “clustername” | Get-VMHost -Name “hostname” | Get-ScsiLun -LunType “Disk” | Set-ScsiLun -MultipathPolicy “roundrobin”

Equally you can use the same command for setting your datastores to MRU as shown below.

Get-Cluster “clustername” | Get-VMHost -Name “hostname” | Get-ScsiLun -LunType “Disk” | Set-ScsiLun -MultipathPolicy “MostRecentlyUsed”