VMware Cloud Community
sivagndl
Enthusiast
Enthusiast

Need script for Cluster

Hi friends,

I need script for Cluster infomation and that cluster avalibale Host and that Host connect the HBA sand WWN  name and Data Store. in Csv format.

pls help me out.  we have one VCs and that haveing 8 Cluster in 90 Esx 4.0 servers.

0 Kudos
2 Replies
john23
Commander
Commander

for this you should use powercli ,this link would be helpful

http://communities.vmware.com/message/1704211

Thanks -A Read my blogs: www.openwriteup.com
0 Kudos
LucD
Leadership
Leadership

Try something like this

$report = foreach($cluster in (Get-Cluster)){
    foreach($esx in (Get-VMHost -Location $cluster)){
        $dsTab = @{}
        foreach($ds in (Get-Datastore -VMHost $esx)){
            if($ds.Extensiondata.Info.Vmfs){
                $ds.Extensiondata.Info.Vmfs.Extent | %{
                    $dsTab[$_.DiskName] = $ds.Name
                }
            }
        }

        foreach($hba in (Get-VMHostHba -VMHost $esx)){
            $hba.ScsiLunUids | %{
                $id = (Select-String "/ScsiLun=(?<runtime>\S+)/$" -InputObject $_).Matches[0].Groups["runtime"].Value
                if($dsTab.ContainsKey($id)){
                    New-Object PSOBject -Property @{
                        Cluster = $cluster.Name
                        Host = $esx.Name
                        HBA = $hba.Name
                        PortWWN = ("{0:x}" -f $hba.PortWorldWideName)
                        LUNid = $id
                        Datastore
= $dsTab[$id]                     }                 }             }         }     } } $report | Export-Csv "C:\report.csv" -NoTypeInformation -UseCulture


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

0 Kudos