# encoding: ascii
# api: powershell
# title: Backup all ESXi
# description: Back up all your ESXi hosts to a local directory.
# version: 0.1
# author: Carter Shanklin
# license: CC0
# x-poshcode-id: 1559
# x-archived: 2009-12-26T18:55:49
#
#
# Change this to where you would like your backups to go.
# There is no versioning so backup theses backups with real backup software (e.g. on an SMB share).
$backupDir = "c:\backups"
# Get just your ESXi hosts.
$esxiHosts = Get-VMHost | Where { $_ | Get-View -Property Config | Where { $_.Config.Product.ProductLineId -eq "embeddedEsx" } }
# Back them all up.
$esxiHosts | Foreach {
$fullPath = $backupDir + "\" + $_.Name
mkdir $fullPath -ea SilentlyContinue | Out-Null
Set-VMHostFirmware -VMHost $_ -BackupConfiguration -DestinationPath $fullPath
}