Keeping a copy of ESXi host configurations is a practical safeguard before maintenance, upgrades, or hardware changes. A PowerShell script based on VMware PowerCLI can automate this task by connecting to each host, exporting the firmware configuration, and storing the backup in a structured folder layout.
The script described here is self-contained. All settings are defined at the top, so no external parameters are required when running it.
How the script works
The first step is to check whether the VMware.PowerCLI module is installed. If it is missing, the script offers to install it automatically. If installation is declined or fails, the script stops immediately so that no backup is attempted without the required module.
After the module check, the script creates a top-level backup folder named with the current date in yyyyMMdd format. This folder becomes the main container for the current run. Using the date in the folder name makes it easy to separate backup jobs from different days.
Inside the dated folder, the script creates one subfolder per ESXi host. The subfolder name includes the host version and build number. This is especially useful when multiple backups are taken on the same day, because it allows a backup from before an update and a backup from after an update to exist side by side without conflict.
Once the structure is created, the script connects to each ESXi host and exports the firmware configuration by using Get-VMHostFirmware -BackupConfiguration. The resulting configuration file is stored in the matching host folder.
Main configuration values
The most important settings are defined at the top of the script:
| Setting / Variable | Description |
|---|---|
$esxhosts | Array of ESXi host IP addresses or hostnames to back up. |
$BackupPath | Base path where backups are stored, combined with the current date to form the backup folder name. |
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore | Configures PowerCLI to accept invalid or self‑signed certificates during ESXi connections. |
This setup keeps the script easy to adapt for different environments without changing the main logic.
Why this structure is useful
The folder layout is intentionally simple but effective. A dated parent folder gives a clear timeline of backup runs, while the version and build information in each subfolder provide additional technical context. That combination makes it easier to trace which backup belongs to which host state and which maintenance action caused the change.
It is also a practical way to handle upgrades. If a host is backed up before an update and then again after the update on the same day, both backups remain available. That makes it much easier to compare the configurations or recover the pre-update state if something goes wrong.
Typical use case
This type of script is especially helpful before patching or replacing ESXi hosts. It gives you a fast way to capture the host configuration without having to document every setting manually. In environments with several hosts, the automation also saves time and reduces the chance of forgetting a backup before making changes.
Download
You can download the script Backup-ESXi-Host-Configurations.ps1 from GitHub here:
Conclusion
Using PowerCLI to back up ESXi host configurations is a clean and reliable way to protect against configuration loss. The script checks for the required module, creates a structured backup layout, and exports each host configuration automatically. For administrators who manage multiple ESXi hosts, this is a simple but very effective safety measure.
This PowerShell script backs up ESXi host configurations using VMware PowerCLI. It first checks if the VMware.PowerCLI module is installed and offers to install it if needed. If installation is declined or fails, the script stops.
Each run creates a top‑level backup folder named with the current date in yyyyMMdd format. Inside, a subfolder is created for each ESXi host, using its version and build number. The script then connects to each host, exports its firmware configuration via Get-VMHostFirmware -BackupConfiguration, and saves the file into the correct folder.
No external parameters are needed. Everything is configured at the top of the script. The main configuration options are:
| Setting / Variable | Description |
|---|---|
$esxhosts | Array of ESXi host IP addresses or hostnames to back up. |
$BackupPath | Base path where backups are stored, combined with the current date to form the backup folder name. |
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore | Configures PowerCLI to accept invalid or self‑signed certificates during ESXi connections. |
You can download the script Backup-ESXi-Host-Configurations.ps1 from GitHub here:
👉