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
Had to omit the semi-colon “;” in line 28 after “.tgz” otherwise script works great!
Removed the semi-colon.Thanks Bryan for the feedback.
Will this script work with VCenter 5.5? i’m getting a bunch of errors when running for PowerCLI 5.5
I get errors stating “The term ‘Set-Customfield’ is not recognized as the name of a cmdlet etc etc