added another host and logic to test if host is online
Without test for host online or other logic to see if backup was successful, the rename code would rename the host folder as the filename variable is blank
This commit is contained in:
@@ -11,12 +11,15 @@ $esxiHosts = @(
|
|||||||
"gauntesxi03.home.johnhgaunt.com"
|
"gauntesxi03.home.johnhgaunt.com"
|
||||||
"gauntesxi04.home.johnhgaunt.com"
|
"gauntesxi04.home.johnhgaunt.com"
|
||||||
"gauntesxi05.home.johnhgaunt.com"
|
"gauntesxi05.home.johnhgaunt.com"
|
||||||
|
"gauntesxi06.home.johnhgaunt.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Loop through each host
|
# Loop through each host
|
||||||
foreach ($esxiHost in $esxiHosts) {
|
foreach ($esxiHost in $esxiHosts) {
|
||||||
#New-VICredentialStoreItem -host $esxiHost -user root -pass ((get-credential).GetNetworkCredential().password); continue
|
#New-VICredentialStoreItem -host $esxiHost -user root -pass ((get-credential).GetNetworkCredential().password); continue
|
||||||
|
|
||||||
|
# Only move forward if host is online or else the rename will rename the host folder
|
||||||
|
if (Test-Connection -Count 1 -Quiet $esxiHost) {
|
||||||
# Backup folder for each host
|
# Backup folder for each host
|
||||||
$backupFolder = "\\gauntnas.home.johnhgaunt.com\veeam$\ESXi Host Configurations\$esxiHost"
|
$backupFolder = "\\gauntnas.home.johnhgaunt.com\veeam$\ESXi Host Configurations\$esxiHost"
|
||||||
|
|
||||||
@@ -51,5 +54,6 @@ foreach ($esxiHost in $esxiHosts) {
|
|||||||
Remove-Item -Force $oldbackup.FullName -verbose
|
Remove-Item -Force $oldbackup.FullName -verbose
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#Stop-Transcript
|
#Stop-Transcript
|
||||||
Reference in New Issue
Block a user