update
This commit is contained in:
22
esxi-scripts/vm-shutdown-verify.ps1
Executable file
22
esxi-scripts/vm-shutdown-verify.ps1
Executable file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env pwsh
|
||||||
|
|
||||||
|
. /opt/idssys/powerwall/settings.ps1
|
||||||
|
|
||||||
|
Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
|
||||||
|
|
||||||
|
Get-Datastore | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Get-VM | if ($_.PowerState -eq "PoweredOn") {
|
||||||
|
Try{
|
||||||
|
$vm = Get-VM -Name $vmName -ErrorAction Stop
|
||||||
|
switch($vm.PowerState){
|
||||||
|
'poweredon' {
|
||||||
|
sleep 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Catch{
|
||||||
|
Write-Host "VM '$($vmName)' not found!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
||||||
@@ -1131,7 +1131,11 @@ SHUTDOWN_SERVER(){
|
|||||||
# ${PW_FOLDER}/esxi-scripts/iscsi-server-shutdown.ps1 ${hostip} >/dev/null 2>&1
|
# ${PW_FOLDER}/esxi-scripts/iscsi-server-shutdown.ps1 ${hostip} >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
echo -e "${idsCL[Green]}Done\n"
|
echo -e "${idsCL[Green]}Done\n"
|
||||||
|
|
||||||
|
echo -en "${idsCL[LightCyan]}Verifying no VMs remain on the host ... "
|
||||||
|
[ "${TEST}" != "true" ] && ${PW_FOLDER}/esxi-scripts/vm-shutdown-verify.ps1 ${hostip} >/dev/null 2>&1
|
||||||
|
echo -e "${idsCL[Green]}Done\n"
|
||||||
|
|
||||||
echo -en "${idsCL[LightCyan]}Shutting down Host ... "
|
echo -en "${idsCL[LightCyan]}Shutting down Host ... "
|
||||||
[ "${TEST}" != "true" ] && ssh root@${hostip} 'esxcli system shutdown poweroff -d 10 -r "Automated ESXi host shutdown"' & >/dev/null 2>&1
|
[ "${TEST}" != "true" ] && ssh root@${hostip} 'esxcli system shutdown poweroff -d 10 -r "Automated ESXi host shutdown"' & >/dev/null 2>&1
|
||||||
echo -e "${idsCL[Green]}Host will begin shutdown in 10secs\n"
|
echo -e "${idsCL[Green]}Host will begin shutdown in 10secs\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user