Hello guys…!!!

Here is script developed to get the No Of Paths per DS and Type of path selection policy and to which VMHBA it is connected.

PowerShell Scrip:

Connect-VIServer -Server servername -User username -password password
$expotDSPathCount=@()
#Get list of ESXi Hosts
$esxihosts=gc C:\hosts.txt
$countofESXi=$esxihosts.Count
For($i = 1; $i -le $esxihosts.count; $i++)
{
ForEach ($esxihost in $esxihosts) {
 $esxi = Get-VMHost -Name $esxihost
 $hbas = $esxi | Get-VMH

ostHba
 ForEach ($hba in $hbas) {
 $scsiluns = $hba | Get-ScsiLun
 ForEach ($scsilun in $scsiluns) { 
 $exportDSPaths=New-Object PSObject
 $scsipaths =$scsilun | Get-Scsilunpath |Select-Object *
 $LunPathPolicy=$scsilun.MultipathPolicy
 $PathCount=$scsipaths.Count
 $LunNaaID=$scsilun.CanonicalName
 $DS=Get-Datastore |Get-View |Where-Object {$_.Info.vmfs.Extent.DiskName -eq $LunNaaID}
 #Write-Host $DS.Name,$LunNaaID,$LunPathPolicy,$PathCount,$hba.Name,$esxi.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "EsxiHost" -Value $esxi.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "DatastoreName" -Value $DS.Name
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "LunNAAID" -Value $LunNaaID
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "MultipathPolicy" -Value $LunPathPolicy
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "LunPathCount" -Value $PathCount
 $exportDSPaths|Add-Member -MemberType NoteProperty -Name "VmHBA Connected" -Value $hba.Name
 $datastore=$DS.Name
 $expotDSPathCount+=$exportDSPaths
 Write-Progress -Activity “Now Scaning $datastore in $hba on $esxi” -status “Found $countofESXi esxi hosts and working on $esxi” -PercentComplete ($i / $esxihosts.count*100)
 }
 }
}
$expotDSPathCount| Export-Csv -NoTypeInformation 'DSPathCountInformation.csv'
}

Sample Out PutDSPathInfo

Advertisement