Configure VMware Datastore Multipath Policy by Disk Type

Here is a VMware vSphere PowerClI script that will find all datastores that are of the model Hitachi – Open-V, set the multipath policy to RoundRobin if it is anything else.

$clustername = ‘clustersomething’
$datastore = get-datastore

# Find datastores by HITACHI, model OPEN-V and multipath not RoundRobin and Change to RoundRobin
$disks = get-cluster $clustername | get-vmhost | get-scsilun -luntype disk | where {$_.Vendor -eq “HITACHI” -And $_.Model -eq “OPEN-V” -And $_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “RoundRobin”

#Test the policy for one ESX host
#$disks = get-vmhost esx-host-name | get-scsilun -luntype disk | where {$_.Vendor -eq “HITACHI” -And $_.Model -eq “OPEN-V” -And $_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “RoundRobin”

$entry = @()
$output = @()
ForEach ($disk in $disks){

$disk | Export-Csv .\disk.txt

$entry = “” | Select DataStorename, HostName, Canonicalname, Multipathing
$entry.datastorename= $datastore | Where-Object {($ | %{$_.diskname}) -contains $disk.canonicalname}|select -expand name
$entry.HostName = $disk.VMHost.Name
$output += $entry
$output | Export-csv ‘c:\apply-multipath-result.csv’

#Write result to screen
#write-output $output

About Andrew Lin

Hi, I have always wanted to creat a blog site but never had the time. I have been working in Information Technology for over 15 years. I specialize mainly in networks and server technologies and dabble a little with the programming aspects. Andrew Lin

View all posts by Andrew Lin →

Leave a Reply

Your email address will not be published. Required fields are marked *