- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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