Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer myvcenter1.test.local

$result=@()

$dstores=Get-Datastore

foreach ($dstore in $dstores)

{

$dstorename=$dstore.name

Write-Host $dstorename

$naadetails=($dstore).ExtensionData.Info.Vmfs.extent

$naa=($naadetails).diskname

$esx=get-datastore $dstore.name|get-vmhost

$esxformat=(@($esx) -join ‘,’)

$naaformat=(@($naa) -join ‘,’)

$properties=@{

name=$dstorename

esxname=$esxformat

naaid=$naaformat

}

$result=New-Object psobject -Property $properties

$result|select name,esxname,naaid|export-csv C:\Users\darshana\Desktop\ds.csv -Append -NoTypeInformation

}