From b74aae923f6c1e9b066c59c4b35d93a69f37c317 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 13 Dec 2023 09:16:11 -0600 Subject: [PATCH] Update iscsi-vm-shutdown-verify.ps1 --- esxi-scripts/iscsi-vm-shutdown-verify.ps1 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/esxi-scripts/iscsi-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-vm-shutdown-verify.ps1 index 073bc658..0edc01b4 100755 --- a/esxi-scripts/iscsi-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-vm-shutdown-verify.ps1 @@ -1,8 +1,9 @@ #!/usr/bin/env pwsh +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +$ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null Get-Datastore | Where {$_.Name -like '*iSCSI-PRI*'} | Get-VM | if ($_.PowerState -eq "PoweredOn") { Try{ @@ -20,3 +21,18 @@ Get-Datastore | Where {$_.Name -like '*iSCSI-PRI*'} | Get-VM | if ($_.PowerState exit 0 + + + +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false +. /opt/idssys/powerwall/settings.ps1 + +$VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-PRI*'} | Get-VM + +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