Update iscsi-sys-vm-shutdown-verify.ps1

This commit is contained in:
2023-12-30 09:16:07 -06:00
parent d330892f4e
commit 32532d1bd5

View File

@@ -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