PowerShell HTML reports for VMware cluster resource utilization
Capacity reviews are easier when evidence is consistent and the file opens without a web server. This guide uses PowerShell to generate HTML reports of VMware cluster resource utilization through the vCenter REST API, then saves a compact local table. It suits lean administration teams needing repeatable snapshots without a full monitoring platform.
Many Australian organisations operate VMware infrastructure alongside public-cloud services. AWS maintains Australian regions in Sydney and Melbourne, VMware Cloud on AWS is available through the Sydney region, and on-premises clusters remain common in Brisbane and Perth. A local HTML snapshot can bridge those environments for morning capacity reviews, branch support and change windows across state offices.
Define report metrics and scope
Define the measurement window before writing code. A point-in-time cluster reading suits a weekly operational review, but it cannot show a lunchtime CPU spike or overnight memory pressure. Record the report period, vCenter name, intended timezone and collection interval so successive files can be compared without guesswork.
Focus the report on CPU, memory and storage utilisation from the cluster resource-usage endpoint. The REST values are expressed in MHz, MB and GB rather than percentages, so pair them with measured usable capacity before making right-sizing decisions. DRS, HA and reservations also affect interpretation; keep per-VM and datastore detail in a separate drill-down.
Authenticate against the vSphere API
Use PowerShell 7 on a host that can reach vCenter. Create a dedicated account with read access only to the target inventory folders; a domain administrator is unnecessary. The URI hostname must match the server certificate, and production automation should trust the internal certificate authority rather than bypass TLS validation.
Create an API session with a prompted credential and keep the session identifier in a header:
$api = 'https://vcenter.example.au'
$cred = Get-Credential -Message 'vCenter read-only account'
$login = @{
user = $cred.UserName
password = $cred.GetNetworkCredential().Password
} | ConvertTo-Json
$session = Invoke-RestMethod -Method Post -Uri "$api/api/session" `
-ContentType 'application/json' -Body $login
$headers = @{ 'vmware-api-session-id' = $session }
$clusters = Invoke-RestMethod -Uri "$api/api/vcenter/cluster" -Headers $headers
Release the session in a finally block with DELETE to /api/session. When fields differ across vSphere builds, independent API testing notes can verify the request shape and expected properties. Record the vCenter build during testing, but never log the password or session token.
Convert API results into report rows
For each cluster returned, query its resource-usage endpoint and retain only the fields needed in the report:
$rows = foreach ($c in $clusters) {
$u = Invoke-RestMethod `
-Uri "$api/api/vcenter/cluster/$($c.cluster)/resource-usage" `
-Headers $headers
[pscustomobject]@{
Cluster = $c.name
CPUUsageMHz = $u.cpu_utilization
MemoryUsageMB = $u.memory_utilization
StorageUsageGB = $u.storage_utilization
}
}
Validate each object and treat null as missing data, not zero. Sort by cluster name for consistent output while retaining original names for traceability. The endpoint provides a snapshot; regular collection and retention are needed for averages, trends and incident evidence.
Create and store the HTML report
PowerShell's ConvertTo-Html -Fragment creates the table and encodes ordinary text values, avoiding hand-built rows that could expose markup embedded in a cluster name. The site's VMware administration guides cover adjacent vSphere configuration and troubleshooting topics that can be paired with these reports.
A compact generation block adds a timestamp, explicit timezone metadata and a local output path:
$output = 'C:\Reports\VMware'
$now = Get-Date
$generated = $now.ToString('yyyy-MM-dd HH:mm:ss zzz')
$fileStamp = $now.ToUniversalTime().ToString('yyyyMMdd-HHmmss')
$path = Join-Path $output ('cluster-{0}.html' -f $fileStamp)
$fragment = $rows | Sort-Object Cluster | ConvertTo-Html -Fragment
@"
<!doctype html>
<html lang="en-AU">
<head>
<meta charset="utf-8">
<title>Cluster report</title>
<style>
body { font-family: Arial; margin: 2rem; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ccc; padding: 0.5rem; text-align: left; }
</style>
</head>
<body>
<h2>VMware cluster resource utilisation</h2>
<p>Generated: $generated ($([TimeZoneInfo]::Local.Id))</p>
$fragment
</body>
</html>
"@ | Set-Content -Path $path -Encoding utf8NoBOM
Test manually before scheduling, then open the file in Microsoft Edge and check its headers and values. On a file server, apply an explicit access list because the report exposes infrastructure naming and topology clues.
Schedule around Australian operations
Use Windows Task Scheduler or a systemd timer on a hardened management host. Australian teams span AEST, AEDT, ACST, AWST and Hobart time, and daylight-saving changes can shift a fixed local trigger. Anchor schedules in UTC, use UTC filenames, include the numeric offset and display an explicit zone label such as Australia/Sydney during operational reviews.
CPU utilisation is not an energy measurement. Australia's National Energy Market covers the eastern states and Tasmania, while Western Australia is separate; tariffs and emission factors vary. Pair capacity reports with host power telemetry or DCIM data when estimating kilowatt-hours rather than converting a CPU percentage into an energy claim.
Secure the reporting pipeline
Store automation credentials in Windows Credential Manager, an approved secrets vault or the platform's protected credential flow; Get-Credential is suitable for prompting but is not a long-term secret store. Restrict report access by role, enable retention limits and prevent the output directory from being indexed publicly. Session identifiers should exist only in memory and be invalidated promptly.
Cluster metrics are usually operational data, but VM and cluster names can contain employee, customer or project identifiers. Where the Privacy Act 1988 applies, minimise those details and assess whether the Australian Privacy Principles and Notifiable Data Breaches scheme affect the intended storage or sharing. Align access controls, patching, backups and logging with the Australian Signals Directorate's Essential Eight where relevant to the organisation's risk context.
Practical recommendations for reliable reports
A dependable report combines accurate collection with clear timing and controlled distribution:
- Use a least-privilege vCenter identity and keep credentials out of scripts, logs and source control.
- Collect at a useful interval and retain timestamped snapshots; one HTML file is not a trend.
- Capture vCenter version, collection interval, timezone and report status with every run.
- Derive cluster-specific thresholds from usable capacity and investigate sustained breaches.
- Encrypt or access-control the report location and remove unnecessary VM or customer names.
- Test task execution after daylight-saving transitions and fail clearly when no cluster data returns.
These controls make the artefact consistent, reviewable and safe to retain: authenticated collection, explicit timing, encoded output and controlled storage remain part of the reporting process.