Update iscsi-vm-shutdown-verify.ps1

This commit is contained in:
2023-12-13 09:16:11 -06:00
parent 1561396f98
commit b74aae923f

View File

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