A quick script to count the number of paths for FC ESxi HBAs for audit and troubleshooting connectivity issues using powercli.
##Count Number of Paths Fibre Channel
$esxName = 'uk3p-esxi01*','uk3p-esx02*','uk3p-esx03*'
$report= @()
$esxilist = Get-VMHost -Name $esxName
foreach( $esxvm in $esxilist){
$esx = Get-VMHost -Name $esxvm
$esxcli = Get-EsxCli -VMHost $esxvm
$hba = Get-VMHostHba -VMHost $esx -TypeFibreChannel | Select -ExpandProperty Name
$esxcli.storage.core.path.list() |
Where{$hba -contains $_.Adapter} |
Group-Object -Property Device | %{
$row = "" | Select ESXihost, Lun, NrPaths
$row.ESXihost = $esxvm.name
$row.Lun = $_.Name
$row.NrPaths = $_.Group.Count
$report += $row
}
}
$report | Export-Csv esx-lun-path.csv -NoTypeInformation -UseCulture
##Count Number of Paths Fibre Channel
$esxName = 'uk3p-esxi01*','uk3p-esx02*','uk3p-esx03*'
$report= @()
$esxilist = Get-VMHost -Name $esxName
foreach( $esxvm in $esxilist){
$esx = Get-VMHost -Name $esxvm
$esxcli = Get-EsxCli -VMHost $esxvm
$hba = Get-VMHostHba -VMHost $esx -TypeFibreChannel | Select -ExpandProperty Name
$esxcli.storage.core.path.list() |
Where{$hba -contains $_.Adapter} |
Group-Object -Property Device | %{
$row = "" | Select ESXihost, Lun, NrPaths
$row.ESXihost = $esxvm.name
$row.Lun = $_.Name
$row.NrPaths = $_.Group.Count
$report += $row
}
}
$report | Export-Csv esx-lun-path.csv -NoTypeInformation -UseCulture
I recently updated my powercli version and realised you can just issue this command to retrieve WWN from a Host
Get-VMHost uk3p-esxi01.lab.local | Get-VMHostHba | ft -a