Hi,
The following script should do, modify the bold and italic line to change the output path:
$output = foreach ($esxi in Get-VMHost | Sort Name)
{
$esxcli = Get-EsxCli -VMHost $esxi
$datastore_info = $esxi.ExtensionData.Config.FileSystemVolume.MountInfo | %{$_.Volume} | Where-Object { if ($_.Name) { $_ } }
foreach ($datastore in $datastore_info | Sort Name)
{
$adapter_information = $esxcli.storage.core.path.list() | Where-Object {$_.Device -match ($datastore.Extent | %{$_.DiskName})}
$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:\Location\output.csv"
Sample Output:
ESXi : abcd.test.com
Datastore : test_volume
Canonical Name : naa.600xxxxxxxxxxxxxxxxxx
RunTimeName : vmhba1:C0:T0:L0,vmhba1:C0:T0:L1
State : active,active
Hope this helps,
Steven.