PoshCode Logo PowerShell Code Repository

Backup all ESXi by Carter Shanklin 29 months ago (modification of post by Carter Shanklin view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/1559"></script>download | new post

Back up all your ESXi hosts to a local directory.

  1. # Change this to where you would like your backups to go.
  2. # There is no versioning so backup theses backups with real backup software (e.g. on an SMB share).
  3. $backupDir = "c:\backups"
  4.  
  5. # Get just your ESXi hosts.
  6. $esxiHosts = Get-VMHost | Where { $_ | Get-View -Property Config | Where { $_.Config.Product.ProductLineId -eq "embeddedEsx" } }
  7.  
  8. # Back them all up.
  9. $esxiHosts | Foreach {
  10.         $fullPath = $backupDir + "\" + $_.Name
  11.         mkdir $fullPath -ea SilentlyContinue | Out-Null
  12.         Set-VMHostFirmware -VMHost $_ -BackupConfiguration -DestinationPath $fullPath
  13. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me