Instead of connecting to all the vCenters at once, you better loop through all of them.
If you have clusters with the same name in multiple vCenters, the numbers in the report will be off.
Do something like this
$Output=@()
$hosts= @(
"10.143.230.245",
"10.143.239.25",
"10.144.143.185",
"10.152.116.185",
"10.152.16.247",
"10.151.116.185",
"10.151.16.247",
"10.208.142.11",
"10.108.22.154",
"10.72.100.15",
"10.143.226.247",
"10.151.116.245",
"10.151.117.55",
"10.152.116.245",
"10.151.117.115",
"10.198.224.5",
"10.160.55.55",
"10.198.224.115",
"10.70.1.187",
"10.143.239.115",
"142.221.126.187",
"10.103.194.187",
"10.103.77.59"
);
$a="<style>"
$a=$a+"BODY{background-color:white;}"
$a=$a+"TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a=$a+"TH{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a=$a+"TD{border-width: 1px;padding: 1px;border-style: solid;border-color: black;background-color:white}"
$a=$a+"</style>"
Write-Host ("Getting Cluster Information from $hosts")
$output=foreach($vcin$hosts){
Connect-VIServer-Server$vc-User""-Password""
Get-Cluster-Server$global:defaultviserver|ForEach-Object-Process {
$ds=Get-Datastore-Name*VSAN*-RelatedObject$_
$esx=Get-VMHost-Location$_
$cpuTot= ($esx|Measure-Object-PropertyCpuTotalMhz-Sum).Sum
$cpuUse= ($esx|Measure-Object-PropertyCpuUsageMhz-Sum).Sum
$memTot= ($esx|Measure-Object-PropertyMemoryTotalGB-Sum).Sum
$memUse= ($esx|Measure-Object-PropertyMemoryUsageGB-Sum).Sum
$obj=[ordered]@{
vCenter =$global:defaultviserver.Name
Cluster =$_.Name
'Total CPU Ghz'=[math]::Round($cpuTot/1000,0)
'CPU Usage'="{0:P0}"-f ($cpuUse/$cpuTot)
'CPU Free'="{0:P0}"-f (($cpuTot-$cpuUse)/$cpuTot)
'Total RAM GB'=[math]::Round($memTot,0)
'RAM Usage'="{0:P0}"-f ($memUse/$memTot)
'RAM Free GB'="{0:P0}"-f (($memTot-$memUse)/$memTot)
'Total Capacity GB'=[math]::Round($ds.CapacityGB,0)
'Used Capacity GB'=[math]::Round($ds.CapacityGB -$ds.FreeSpaceGB,0)
'Free Capacity GB'=[math]::Round($ds.FreeSpaceGB,0)
'N° Hosts'=$_.ExtensionData.Host.Count
'N°VMs'= (Get-View-Id (Get-View-Id$_.ExtensionData.Host -PropertyVM).VM -PropertySummary.Config.Template|where{-not$_.Summary.Config.Template}).Count
}
New-ObjectPSObject-Property$obj
}
Disconnect-VIServer$vc-confirm:$false
}
$output|ConvertTo-Html-Head$a|Out-FileC:\Users\nicolas.porta\Desktop\xrails.htm-width400