VMware Cloud Community
ccastell
Contributor
Contributor

Script needed

Does anyone have a script that runs against clusters to gather each esxi hosts hba devices\targets and paths counts in a nice excel spreadsheet. have the san team doing some upgrades this week and need to make sure these counts are the same before and after the upgrade.  I have attempted several i found through my internet searches but i am striking out.  hosts are all 5.5.  thanks in advance.

0 Kudos
3 Replies
LucD
Leadership
Leadership

You mean something like this ?

$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName |

Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_

        $hba = $esxcli.storage.core.adapter.list() | where{$_.LinkState -eq 'link-up'} | Select -ExpandProperty HBAName

        $esxcli.storage.core.path.list() |

        Where{$hba -contains $_.Adapter -and $_.State -eq 'Active'} |

        Group-Object -Property Device |

        Select @{N='Cluster';E={$clusterName}},

            @{N='VMHost';E={$esxcli.VMhost.Name}},

            @{N='HBA';E={$_.Group[0].Adapter}},

            @{N='LUN';E={$_.Name}},

            @{N='#Path';E={$_.Group.Count}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ccastell
Contributor
Contributor

This is almost what i am looking for lucd,  This is showing me how many paths each lun has.  I just need a list of for each active hba to show Targets devices and Paths.  And i want to be able to do this per cluster.  Thanks for getting back to me so fast!!

Capture.PNG

0 Kudos
LucD
Leadership
Leadership

Try this version

$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName |

Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_

        $ESXCLI.storage.core.path.list() |

        where{$_.State -eq 'active' -and $_.Transport -eq 'fc'} |

        Group-Object -Property adapter,device |

        Select @{N='Cluster';E={$clusterName}},

            @{N='VMHost';E={$esxcli.VMhost.Name}},

            @{N='HBA';E={$_.Name.Split(',')[0].Trim(' ')}},

            @{N='LUN';E={$_.Name.Split(',')[1].Trim(' ')}},

            @{N='#Path';E={$_.Group.Count}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos