# Change these variables to suit your environment | |
$BackupPath = "d:\Backups\ESXi\" | |
$ArchivePath = "d:\Backups\ESXi\Archive\" | |
$vCenterServer = "myvcentreserver.mynetwork.com" | |
#Zip up existing backup files and Manifest into the Archive Directory | |
Compress-Archive -Path ($BackupPath + 'configBundle*.tgz'), ($BackupPath + 'Manifest*.txt') -DestinationPath ($ArchivePath + 'ESXiBackup' + (Get-Date -Format yyyyMMdd) + '_' + (Get-Date -Format HHmm) + '.zip') | |
Remove-Item ($BackupPath + '*.tgz') | |
Remove-Item ($BackupPath + 'Manifest*.txt') | |
# Set powershell to ignore certificate errors, you can comment this out if you are using trusted certs in your environment | |
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | |
#Connect to the vCenter Server. You can also connect directly to a single ESXi host | |
Connect-VIServer -Server $vCenterServer | |
#Enumerate all of the ESXi hosts and backup the configs to the Backup Directory | |
Get-VMHost | Get-VMHostFirmware -BackupConfiguration -DestinationPath $BackupPath | |
#Enumerate all of the ESXi hosts and record the Name, Version and Build in the Manifest file | |
Get-VMHost | Select Name,Version,Build | Out-File ($BackupPath + 'Manifest' + '_' + (Get-Date -Format yyyyMMdd) + '_' + (Get-Date -Format HHmm) + '.txt') | |
#Disconnect from the vCenter Server | |
disconnect-viserver -confirm:$false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment