List the multipath policy per datastore

Some jobs require several mouse-clicks to get the information you need. If this is for a limited amount of checks, doing it this way is more than acceptable. However in my situation I needed to check a vSphere 5.0 vcenter with 9 clusters, 49 hosts and 931 virtual machines. My task was to document each datastore together with the defined MultipathPolicy. I thought it would be a simple task with a PowerShell command that looks like this: get-datastore | select name,multipathpolicy or get-scsilun -luntype disk | select name,multipathpolicy.

In fact the solution is more complex than expected. If you want the human readable names of the datastores, you need to filter out the name by using the ExtensionData.

FOREACH($vmHost in (Get-VMHost))
Write-Warning "Grabbing Data for $vmhost"
FOReach($lun in ($vmHost|Get-ScsiLun -luntype Disk))
$collect=""| select "Host","Datastore","Canonicalname", "MultipathPolicy"
$Datastore=(Get-Datastore|?{($|select -expand diskname) -like $canon}).name
$output | Out-File C:\datastoresprod.csv

Credit goes to the persons who deserve it.