From b286ff77def2ab7ea2d49b1d139795907e1bdcf7 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Fri, 2 Feb 2024 08:46:03 -0600 Subject: [PATCH] update --- esxi-scripts/vm-shutdown.ps1 | 10 +++++++++- powerwall.sh | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/esxi-scripts/vm-shutdown.ps1 b/esxi-scripts/vm-shutdown.ps1 index e84a6bf1..0da8596c 100755 --- a/esxi-scripts/vm-shutdown.ps1 +++ b/esxi-scripts/vm-shutdown.ps1 @@ -6,7 +6,15 @@ Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Passwo $vmhosts=$args[0].Split(",") Foreach ($vmhost in $vmhosts) { - Get-VMHost | Where {$_.Name -eq $vmhost} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Shutdown-VMGuest -Confirm:$false + $vms=Get-VMHost | Where {$_.Name -eq $vmhost} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} + Foreach ($vm in $vms) + { + $migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Relocate*' -and $_.State -eq 'Running'} + if ([string]::IsNullOrEmpty($migrating)) { + write-host "Shutting down "+$vm + #Get-VM $vm | Shutdown-VMGuest -Confirm:$false + } + } } Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/powerwall.sh b/powerwall.sh index c201e407..981ed539 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -343,7 +343,7 @@ SHUTDOWN_SERVER(){ c=0; MSG_SPC=''; spc1=`expr ${HC_CW} - ${#MSG}`; until [ ${c} = ${spc1} ]; do MSG_SPC="${MSG_SPC} "; ((c++)); done echo -en "${idsCL[White]}${MSG}${MSG_SPC}: " if [ "${TEST}" != "true" ]; then - sleep 35s + sleep 45s echo -e "${idsCL[Green]}Done${idsCL[Default]}" else echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}"