PowerCLI To Set Mulitpath Policy To Round Robin

As a part of my job, I am constantly going through VMware infrastructure looking for ways to fine tune and check settings for best practices. One of the more common things I find when looking through Fiber Channel storage settings is the multipathing policy not being set properly. Most of the clients I run across are using HP 3Par for storage, according to the best practices guide, HP recommends that the multipath policy be set to Round Robin. The script below will set the multipath policy on all fiber channel storage connections to Round Robin.


#Setting Storage Luns to Round Robin 

$VC = Read-Host " Enter vCenter name:" 

Connect-VIServer $VC


Get-Cluster | Select name | FT

$Cluster = Read-Host " Enter Cluster name from list above:"

$VMhosts = Get-cluster $cluster | Get-VMHost 

Foreach ($VMhost in $VMhosts) {

      Write-Host "SettingMultipath Policy on $VMhost to Round Robin" -ForegroundColor Green

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

      Get-VMhost $VMhost | Get-ScsiLun -LunType Disk | Where-Object {$_.CanonicalName-like ‘naa.*’ -and $_.MultipathPolicy-like ‘RoundRobin’} | Set-ScsiLun -CommandsToSwitchPath 1



Write-host "disconnecting from $VC" -ForegroundColor Yellow

Disconnect-VIServer -Server * -Confirm:$False