VMware Cloud Community
ZAK-Admin
Contributor
Contributor

Powercli script for HBA/Host details required

Hello,

we have around 300 production ESXi host, each has 4 online vmhba but only two has targets and paths while other two has 0 targets/paths.

we're looking for script to list each ESXi host name & vmhba# & WWN & number of targets to unzone 0 targets vmhba to free fabric ports.

we tried LucD below script but it doesn't give WWN, wish if there any help to add WWN to the script.

----------------------------------------------------------

foreach($esx in Get-VMHost){

    foreach($hba in (Get-VMHostHba -VMHost $esx -Type "FibreChannel")){

        $target = ((Get-View $hba.VMhost).Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -eq $hba.Key}).Target

        $luns = Get-ScsiLun -Hba $hba  -LunType "disk" -ErrorAction SilentlyContinue

        $nrPaths = ($target | %{$_.Lun.Count} | Measure-Object -Sum).Sum

 

        $props = [ordered]@{

            VMHost = $esx.name

            HBA = $hba.Name

            Targets = $target.Count

            Devices = $luns.Count

            Paths = $nrPaths

        }

        New-Object PSObject -Property $props

    }

}

 

Thanks in Advance

0 Kudos
2 Replies
LucD
Leadership
Leadership

0 Kudos
ZAK-Admin
Contributor
Contributor

we spent 6 hours trying within all URL you mentioned as we understand you shouldn't work for the community but no luck.

the issue we can't merge below two scripts shown on below screenshot. if you can help this will save us a lot 

ZAK-Admin_0-1623326847774.png

we're looking for output similar to :

VMHost : x.y.z
HBA : vmhba64
WWPN : x.y.z
Targets : 4
Devices : 31
Paths : 62

 

Thanks LucD

0 Kudos