There sure is. Here is an example, using Power-CLI:
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
$backupbasedir = "<Base directory to store the backups>"
$username = "<Username with the correct right in vCenter>"
$password = "<Password for that user>"
$VCenterServer = "<FQDN of the vCenter server>"
if ($backupbasedir.Substring($backupbasedir.Length - 1, 1) -ne "\") {
$path = $backupbasedir + "\"
}
else {
$path = $backupbasedir
}
Connect-VIServer $VCenterServer -User $username -Password $password
Get-VMHost | ForEach-Object {
$path = $path + $_ + "\" + $_.ExtensionData.Config.Product.Version + "\" + $_.ExtensionData.Config.Product.Build
if (!(Test-Path $path)) { New-Item -ItemType directory -Path $path }
Get-VMHostFirmware -VMHost $_ -BackupConfiguration -DestinationPath $path
}
This script first disables the error message when certificate errors happen, and then in goes through all of the hosts on a particular vCenter and backs up their config to a directory structure of "\ServerName\ESXiVersion\BuildNumber"
This makes rebuilding a particular host very easy...
- Reinstall the correct major version of ESXi.
- Patch it to the correct build number of your latest backup. The easiest way I have found to do that is to use the
esxcli software profile update
command and point it to the proper download location for the build number you need. A list of the correct locations was found at https://tinkertry.com/easy-update-to-latest-esxi at the time of this post.
- Restore the latest backup with the "Set-VMHostFirmware" command:
Set-VMHostFirmware -VMHost ESXi_host_IP_address -Restore -SourcePath <Backup Location>
- Reboot and reconnect.