'VMware-BackupESXiConfigFile.ps1'
#This script assumes you have loaded PowerCli modules
#Install-Module VMware.PowerCLI
#https://docs.vmware.com/en/VMware-vSphere/7.0/com.vmware.esxi.install.doc/GUID-F02D0C2D-B226-4908-9E5C-2E783D41FE2D.html
#Set input
$ESXIs = gc D:\powershell\input\esxihostnames.txt #<-- you can obtain the ESXi list by PS script get-esxihost
#Set output
md D:\PowerShell\output\ESXI-ConfigBackups -Force -ea SilentlyContinue -wa SilentlyContinue -InfA SilentlyContinue|out-null
#Set Credentials
#See related Posts to create these scripts
. .\Set-PSCredential-ForVMware-Account.ps1
. .\Set-PSCredential-ForESXI-Account.ps1
#Set VIserver
$VIserver = Read-Host -Prompt "What VCSA/VIserver/VCenter do you want to connect to?"
#Connect VIServer
Connect-VIServer -Server $VIserver -ea SilentlyContinue -Credential $PSCredential_VMWARE -Verbose
#Walk through each ESXi host and run the command
foreach ($ESXI in $ESXIs){
Get-ESX -Server $ESXI -Credential $PSCredential_ESXi -ea SilentlyContinue -Verbose;
#Set output - you can remove Verbose switches and mute output with '-ea silentlycontinue' or a pipe put to out-null if you want - I like the responses myself
Write-host "Now connected to $ESXI"
#Export Config - version 7 and up - version 6 uses IPV4 addresses
#https://kb.vmware.com/s/article/2042141
Get-VMHostFirmware -Server $VIserver -VMHost "$ESXI" -BackupConfiguration -DestinationPath D:\PowerShell\output\ESXI-ConfigBackups -Verbose
}
#You use the same command to connect to the ESXi hosts as VIservers
#Name Category Module Synopsis
#---- -------- ------ --------
#Get-ESX Alias Connect-VIServer