Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | ft –autosize
Copy output to text file and then open with Excel as below, adding the CapacityGB, Name and LunID columns. Use the vCenter GUI to obtain LUN IDs that can then be translated into the correct name as per the your sites LUN/Datastore naming convention.
Save the new CSV file to C:\new_datastores.csv
Now create the script to perform the task, copy the text below into C:\storage_setup.ps1. Modify the text in RED to suit your environment:
write “Importing CSV: $($CSVFile)”
$CSV = Import-CSV $CSVFile
Foreach ($Item in $CSV){
$HostID = $Item.HostId
$LunID = $Item.LunID
$LunPath = $Item.CanonicalName
$Name = $Item.Name
Write “Creating: $($Name)…Path: $($LunPath) “
Write “Created, applying RoundRobin multipathing policy… for cluster: $($vmcluster) “
foreach ($vmhost in get-cluster $vmcluster| get-vmhost) {
write node: $($vmhost.Name)
Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “$($LunPath)” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”}
Open the vSphere PowrCLI and connect to your vCenter; connect-viserver vCentername
Now execute the new script saved above.
Finally, if you are using Enterprise Plus, use the vCenter GUI to set Storage IO Control, this is a drop down box that can be set across all hosts with one change per datastore.