Using PowerCLI to audit vSphere compliance against security baselines

A repeatable PowerCLI audit turns scattered vSphere Client observations into reviewable evidence. A practical workflow inventories vCenter Server, ESXi hosts, virtual machines, datastores, virtual networks, identities, and configuration drift before comparing them with an approved benchmark. For Australian teams, the resulting controls should support the Australian Signals Directorate’s Essential Eight and relevant Australian Cyber Security Centre guidance while remaining traceable to a defined compliance scope.

A useful audit does not declare that a platform is compliant simply because a script returns no errors. Instead, it records expected and observed values, severity, evidence, exceptions, and remediation ownership. Run collection in UTC because Australian daylight-saving changes between AEST and AEDT can otherwise distort incident windows and audit trails. Where workloads sit in Sydney, Melbourne, or another approved Australian region, capture the location and applicable contractual obligations without assuming every dataset has a universal residency rule.

Approach Main strength Main limitation Best fit
Manual vSphere review Familiar and contextual Slow and inconsistent Small, one-off checks
PowerCLI script Repeatable and exportable Requires access and test data Scheduled evidence collection
Configuration management platform Policy-as-code and approvals More setup and integration Large or regulated estates

Define the control baseline

Start by naming the authoritative baseline rather than collecting every exposed setting. CIS VMware benchmarks, vendor hardening guidance, internal architecture standards, and contractual requirements can all contribute, but each source needs a version, owner, and review date. Store the result as version-controlled YAML or JSON with a stable control ID, expected value, severity, evidence requirement, and approved exception process.

Map those controls to business risks and obligations without claiming that a CIS benchmark automatically satisfies the Essential Eight. If the estate processes Australian personal information, document how the assessment addresses the Privacy Act 1988 and OAIC guidance, plus relevant state, sector, or customer requirements. The Privacy Act does not impose a blanket data-residency rule, so location and subcontractor decisions should follow actual risk and legal advice.

Prepare PowerCLI and least-privilege access

Install the supported VMware.PowerCLI module, connect with a dedicated read-only service account, and confirm the server time before collection:

Install-Module -Name VMware.PowerCLI -Scope CurrentUser
Connect-VIServer -Server vcenter.example.com -Credential (Get-Credential)

Give the account only the inventory and configuration-read permissions required for vCenter, ESXi, storage, and networking objects. Where Active Directory provides access, require MFA at the identity layer and use time-bounded elevation for corrective work rather than granting permanent administrator rights. Never embed credentials in scripts, and check module compatibility with the installed vSphere release. Australian VMware and Broadcom partner documentation and local reseller support remain useful references when version differences affect cmdlet behaviour.

Audit hosts, virtual machines, and storage

Begin with a timestamped inventory so every later finding has a known scope:

$evidence = [ordered]@{
    CapturedAtUtc = (Get-Date).ToUniversalTime().ToString('o')
    Hosts = @(Get-VMHost | Select-Object Name, PowerState, ConnectionState)
    VMs = @(Get-VM | Select-Object Name, PowerState)
    Datastores = @(Get-Datastore | Select-Object Name, Type, Capacity, FreeSpace)
    Roles = @(Get-VIRole)
}

$evidence | ConvertTo-Json -Depth 4 |
    Set-Content -Path ./vSphere-baseline.json

Expand the inventory into assertions: verify ESXi patch level, lockdown mode, Secure Boot or Secure ESXBoot state, NTP sources, local account policy, and management network isolation. Compare virtual machine templates with hardened standards, check for unnecessary virtual hardware, and confirm datastore encryption where it is required. Some advanced ESXi settings are exposed through Get-EsxCli rather than high-level cmdlets, so preserve the raw response and document its API path. Run the first pass read-only and compare the result with both the baseline and the previous run.

Review network and identity controls

Audit identity and authorisation before trusting the configuration snapshot. Inventory local ESXi accounts, vCenter roles, permissions, Active Directory mappings, certificate expiry, session timeout, and emergency access:

Get-VMHostAccount
Get-VIRole
Get-VIPermission

Flag generic administrator assignments, dormant accounts, excessive privileges, and local root use outside the break-glass procedure. Verify that vCenter uses federated identity, MFA, least privilege, and supported certificate validation. Then inspect management VLANs, ESXi management interfaces, port groups, virtual switches, uplinks, and host firewalls; a visually correct vSwitch can still violate policy. When traffic-path evidence is disputed, the distributed switch troubleshooting guide helps separate a configuration defect from a routing or binding issue. Export vCenter, ESXi, and firewall logs to the approved SIEM, and test alert delivery rather than merely confirming that log forwarding is enabled.

Turn findings into evidence and remediation

Translate raw output into findings with one row per control. Each row should contain the control ID, asset, expected value, observed value, severity, evidence timestamp, assessor, ticket, and exception expiry; store attachments or hashes where screenshots are required. Redact passwords, tokens, sensitive variables, and unnecessary personal data. CSV works well for spreadsheet review, while JSON is usually better for automation and a PowerShell audit trail.

Remediate in small, approved batches: apply one change, validate the affected object, capture fresh evidence, and retain a rollback path. Use Get and Set command pairs to preview the target state, and use -WhatIf where a cmdlet genuinely supports it. For teams without spare capacity, the home lab deployment guide provides a practical way to rehearse host, datastore, and network changes before they touch production. Exceptions should name an owner, compensating control, review date, and business justification rather than becoming a permanent way to pass the audit.

Establish a repeatable compliance rhythm

Make the audit part of the operational rhythm rather than an annual report. Run it after hypervisor patching, vCenter upgrades, network changes, and access reviews; schedule recurring read-only collection as a second safety net. Keep baselines in Git, link accepted deviations to change records, and have security owners approve both new controls and retired checks.

Start today with one read-only inventory of a non-critical vCenter or ESXi host. Convert the captured settings into explicit pass, fail, or not-applicable assertions, agree the evidence format with the compliance owner, and schedule the second collection before changing any production configuration.

The first successful cycle should produce a scoped evidence bundle, a prioritised remediation list, and an owned follow-up date. That gives the Australian infrastructure team an auditable vSphere compliance record without turning security baselining into spreadsheet archaeology.