PoshCode Archive  Artifact [4bb4b2b3de]

Artifact 4bb4b2b3dea36a3900565f30c8338ff094943ad5663fd179f946b117853a9408:

  • File Backup-all-ESXi.ps1 — part of check-in [7ca477692b] at 2018-06-10 12:58:30 on branch trunk — Back up all your ESXi hosts to a local directory. (user: Carter Shanklin size: 858)

# 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: 1558
# x-archived: 2012-12-17T22:03:05
# x-published: 2012-12-23T10:37: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 $_ -BackupConfiguration -DestinationPath $fullPath
}