diff --git a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 index f7fa23a5..5468a490 100755 --- a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 @@ -19,8 +19,10 @@ Do { if ($VMLIST -ne $null) { write-host "cycling through iscsi vms found" $poff = 'no' - Foreach ($VM in $VMLIST) { - if ((Get-VM $VM).PowerState -match 'PoweredOn') { + Foreach ($VM in $VMLIST) { + if ((Get-VM $VM) -eq $null) { + break + } elseif ((Get-VM $VM).PowerState -match 'PoweredOn') { break } else { $poff = 'yes'