Nice script.
If I might suggest the following small change.
This version will only show VMFS volumes and take into account that there might be multi-extent VMFS datastores.
$output=foreach ($esxiinGet-VMHost|SortName)
{
$esxcli=Get-EsxCli-VMHost$esxi
$datastore_info=$esxi.ExtensionData.Config.FileSystemVolume.MountInfo|%{$_.Volume} |Where-Object { if ($_.Name) { $_ } }
foreach ($datastorein$datastore_info|SortName)
{
$esxcli.storage.vmfs.extent.list() |where {$_.VolumeName-eq$datastore.Name} |%{
$adapter_information=$esxcli.storage.core.path.list($_.DeviceName)
$datastore|Select-Object@{N="ESXi";E={$esxi.Name}},
@{N="Datastore";E={$datastore.Name}},
@{N="Canonical Name";E={$datastore.Extent|%{$_.DiskName}}},
@{N="RunTimeName";E={[string]::Join(",", ($adapter_information|%{$_.RunTimeName}))}},
@{N="State";E={[string]::Join(",", ($adapter_information|%{$_.State}))}}
}
}
}
$output|Export-Csv"C:\output.csv" -UseCulture