VMware PowerCli Script to collect all Cluster information

Following Script will collect All clusters information from vCenter and output will be stored in ClusterInfo.csv file
——————————————

$reportFinal = @()
$ClsName = Get-Cluster
foreach ($cls in $ClsName ){
        $clshost = Get-Cluster $cls | Get-VMHost
        foreach ($vmhost in $clshost) {
        $hostview = $vmhost |get-View
        $hostinfo = {}|select Cluster, ESX_IP, Hostname, Model, ProcessorType, NumCPU, CPUSpeedMhz, MemoryMB, OS, ProductLine, Build
        $hostinfo.Cluster = Get-Cluster -VMHost $vmhost
        $hostinfo.ESX_IP = $vmhost.name
        $hostinfo.Hostname = $hostview.config.network.dnsConfig.hostname
        $hostinfo.Model = $vmhost.model
        $hostinfo.ProcessorType = $vmhost.ProcessorType
        $hostinfo.NumCPU = $vmhost.NumCPU
        $hostinfo.CPUSpeedmhz = $vmhost.cputotalmhz
        $hostinfo.memoryMB = $vmhost.memorytotalmb
        $hostinfo.OS = $hostview.summary.config.product.fullname
        $hostinfo.ProductLine  = $hostview.summary.config.product.productlineid
        $hostinfo.Build = $hostview.config.product.build
        $reportFinal += $hostinfo
        }
    }
    $reportFinal |Sort Cluster, ESX_IP |Export-Csv ClusterInfo.csv -NoTypeInformation

Leave a Reply

Your email address will not be published. Required fields are marked *