﻿# encoding: utf-8
# 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: 1557
# x-archived: 2013-01-16T10:23:25
# x-published: 2010-12-23T10:17:00
#
#
# 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 $_ ¨CBackupConfiguration ¨CDestinationPath $fullPath
}
