AdamUK
Enthusiast
Enthusiast

That appears to display the figures in the table against each VM rather than separately.  What I was looking for was something like the following although the ClusterHosts and ClusterVMs fields do not display the details correctly (the ClusterName is reported correctly for all cluster instances).  The html configuration is something I am working on for display purposes so I have defined $html (and $export_html & $Dateformat) separately

$total_vms = (Get-VM).count

$reportcluster = @()

foreach ($dc in Get-Datacenter) {

    foreach ($cluster in Get-Cluster -Location $dc){

$infocluster = "" | select ClusterName, ClusterHosts, ClusterVMs

$infocluster.ClusterName = $cluster

$infocluster.ClusterHosts = (get-cluster | select @{n="hosts";e={($_ | get-vmhost).count}}) -join '|'

$infocluster.ClusterVMs =  (get-cluster | select @{n="vms";e={($_ | get-vm).count}}) -join '|'

$reportcluster += $infocluster

      }

}

$reportcluster | Sort-Object -Property ClusterName | ConvertTo-Html -Head $html -Body "<h1> Report run on: $Dateformat</h1><h2>Total number of VMs across all Data Centres/Clusters: $total_vms</h2>" | Out-File $export_html

Reply
0 Kudos