PoshCode Archive  Artifact [e8ddf01b3f]

Artifact e8ddf01b3fc8b283621b8c740db28e6272981b76269a48cbc2ca38f5c72a0a7a:

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

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