Hello guys…

Here is the script  to get the Number of Paths for each and every VMHBA in esxi and the out put will be saved in CSV Files…Thanks to Lucd…

Script:

Connect-VIServer -Server vcenterservername -User vcenterusername -password vcenterpassword
$exportData=@()
$esxs=gc C:\Users\TIRU\hosts.txt
foreach($esxi in $esxs){
$esx = Get-VMHost -Name $esxi
foreach($hba in (Get-VMHostHba -VMHost $esx ))
{
$target = ($hba.VMhost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -eq $hba.Key}).Target
$luns = Get-ScsiLun -Hba $hba 
$nrPaths = ($target | %{$_.Lun.Count} | Measure-Object -Sum).Sum
$exportObject=New-Object PSObject 
$exportObject |Add-Member -MemberType NoteProperty -Name "HostName" -Value $esx
$exportObject |Add-Member -MemberType NoteProperty -Name "HBAName" -Value $hba.Device
$exportObject |Add-Member -MemberType NoteProperty -Name "NumberOfPaths" -Value $nrPaths
#NumberOfPaths=$nrPaths
#HostName=$esx
#HBAName=$hba.Device
#NumberOfTargets=$target.Count
#NumberOfDevices=$luns.Count
$exportData+=$exportObject
}
}
$exportData| Export-Csv -NoTypeInformation 'ESXiStoragePathInformation.csv' 

Sample Output:

SampleOutput Of Script

Advertisement