Skip to content

Instantly share code, notes, and snippets.

@hospitableit
Last active February 23, 2019 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hospitableit/2e3a144d830d6b0456466a4a4459dedb to your computer and use it in GitHub Desktop.
Save hospitableit/2e3a144d830d6b0456466a4a4459dedb to your computer and use it in GitHub Desktop.
# 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