Files
powerwall/esxi-scripts/vm-shutdown-verify.ps1
2023-12-13 18:40:41 -06:00

16 lines
527 B
PowerShell
Executable File

#!/usr/bin/env pwsh
# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
. /opt/idssys/powerwall/settings.ps1
$ESXI = Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null
$VMLIST = Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'}
Foreach ($VM in $VMLIST) {
while((Get-VM $VM).PowerState -ne 'PoweredOff') {
Start-Sleep -Seconds 1
}
}
Disconnect-VIServer $ESXI -Confirm:$false