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