diff --git a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 index aba18b0b..6dbbadc1 100755 --- a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 @@ -5,12 +5,26 @@ $ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null -$VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM +# $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM +# +# Foreach ($VM in $VMLIST) { +# while((Get-VM $VM).PowerState -ne 'PoweredOff') { +# Start-Sleep -Seconds 1 +# } +# } + +Do { + $poff = yes + $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM + Foreach ($VM in $VMLIST) { + if ((Get-VM $VM).PowerState -eq 'PoweredOn') { + $poff = no + } + } +} Until ($poff -eq yes) + + + -Foreach ($VM in $VMLIST) { - while((Get-VM $VM).PowerState -ne 'PoweredOff') { - Start-Sleep -Seconds 1 - } -} Disconnect-VIServer $ESXI -Confirm:$false \ No newline at end of file