Reply to Message

View discussion in a popup

Replying to:
LucD
Leadership
Leadership

Try like this

$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-VMHost -Location $_).count

        $infocluster.ClusterVMs = (Get-VM -Location $_).Count

        $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


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

Reply
0 Kudos