PoshCode Archive  Artifact [dd2691635e]

Artifact dd2691635e33f05e55fa7aed4d8b3d64251b6e4ac556f19218fae667611cf2d6:

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

# 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
}