diff --git a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 index fe569960..0abba8d1 100755 --- a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 @@ -15,12 +15,20 @@ $ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -P Do { $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM - $poff = 'no' write-host $VMLIST if ($VMLIST -ne $null) { - write-host "iscsi vms found" + write-host "cycling through iscsi vms found" + $poff = 'no' + Foreach ($VM in $VMLIST) { + $VMI = Get-VM $VM + if ($VMI -eq $null -Or $VMI.PowerState -match 'PoweredOn') { + break + } else { + $poff = 'yes' + } + } } else { - write-host "NO iscsi vms found" + write-host "no iscsi vms found" $poff = 'yes' } } Until ($poff -match 'yes')