diff --git a/esxi-scripts/vm-shutdown.ps1 b/esxi-scripts/vm-shutdown.ps1 index 41b90769..dfebcfd0 100755 --- a/esxi-scripts/vm-shutdown.ps1 +++ b/esxi-scripts/vm-shutdown.ps1 @@ -1,10 +1,14 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null -Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Shutdown-VMGuest -Confirm:$false +#Get-VMHost | Where {$args[0]} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} | Shutdown-VMGuest -Confirm:$false -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Get-VMHost | Where {$args[0]} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} + +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false + + + +#$_.Name -eq 'ids-vms1.scity.us' -or $_.Name -eq 'ids-vms7.scity.us' \ No newline at end of file diff --git a/powerwall.sh b/powerwall.sh index ca5f45cb..c17f8ac7 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -363,23 +363,33 @@ SHUTDOWN_SERVER(){ echo -en "${idsCL[White]}${MSG}${idsCL[White]}${MSG_SPC}: " # for ESXIHOST in "${PW_MAINSITEHOSTS[@]}"; do if [ "${TEST}" != "true" ]; then + if [ "${1}" == "10.10.2.10" ] || [ "${1}" == "MAIN" ]; then + ${PW_FOLDER}/esxi-scripts/iscsi-vm-shutdown-verify.ps1 >/dev/null 2>&1 + elif [ "${1}" == "10.10.2.17" ] || [ "${1}" == "SYS" ]; then + ${PW_FOLDER}/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 >/dev/null 2>&1 + elif [ "${1}" == "MAINSITE" ] || [ "${1}" == "ALL" ]; then + ${PW_FOLDER}/esxi-scripts/iscsi-all-shutdown-verify.ps1 >/dev/null 2>&1 + fi + echo -e "${idsCL[Green]}Done${idsCL[Default]}" # if [ "$(ipmitool -I lanplus -H ${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${ESXIHOST}]}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power status | grep 'Power is on')" != "" ] && [ "$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ESXIHOST} 'esxcli system maintenanceMode get')" != "Enabled" ]; then - VERIFY_ISCSI_VM_DOWN "${ESXI_HOST}" & + # VERIFY_ISCSI_VM_DOWN "${ESXI_HOST}" & # else # touch ${PW_TMPFOLDER}/verify.iscsi.${ESXIHOST}.done # fi + else + echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}" fi # done - if [ "${TEST}" != "true" ]; then - nc_count=0 - until [ -f ${PW_TMPFOLDER}/verify.iscsi.done ]; do - sleep 1s - done - echo -e "${idsCL[Green]}Done${idsCL[Default]}" - else - echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}" - fi + # if [ "${TEST}" != "true" ]; then + # nc_count=0 + # until [ -f ${PW_TMPFOLDER}/verify.iscsi.done ]; do + # sleep 1s + # done + # echo -e "${idsCL[Green]}Done${idsCL[Default]}" + # else + # echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}" + # fi if [ "${ESXI_HOST}" == "10.10.2.10" ] || [ "${ESXI_HOST}" == "MAIN" ] || [ "${ESXI_HOST}" == "CONSERVE" ]; then MSG="Shutting down iSCSI-PRI Server"