Backup the ESXi configuration

I create a simple PowerCLI script that backups all the VMware ESXi host configurations that are connected to a vCenter Server. This script can be scheduled to make for example every week a backup of the ESXi server configs. You can easily customize the script for your own needs.

#Variables
$Folder = "D:\Backup\BCK-ESXi"
$FolderOld = "D:\Backup\BCK-ESXi\_old"
$vc= "vcenterserver-fqdn"
# Connect to local vCenter Server
Connect-ViServer
# Move existing backup files to the old directory
Move-Item ($Folder + "\*.tgz") $FolderOld -force -ErrorAction SilentlyContinue
# Backkup ESXi configuration
Get-VMHost | ForEach-Object {
    $_ | Get-VMHostFirmware -BackupConfiguration -DestinationPath $folder
}
# Disconnect session vCenter
Disconnect-VIserver -Confirm:$false

4 thoughts on “Backup the ESXi configuration”

  1. Will this script work with VCenter 5.5? i’m getting a bunch of errors when running for PowerCLI 5.5

  2. I get errors stating “The term ‘Set-Customfield’ is not recognized as the name of a cmdlet etc etc

Leave a Comment