Skip to content

Instantly share code, notes, and snippets.

Last active February 23, 2019 04:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# Change these variables to suit your environment
$BackupPath = "d:\Backups\ESXi\"
$ArchivePath = "d:\Backups\ESXi\Archive\"
$vCenterServer = ""
#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