diff --git a/esxi-scripts/offsite-vm-shutdown.ps1 b/esxi-scripts/offsite-vm-shutdown.ps1 index 3081e16e..9d206ca4 100755 --- a/esxi-scripts/offsite-vm-shutdown.ps1 +++ b/esxi-scripts/offsite-vm-shutdown.ps1 @@ -1,10 +1,9 @@ #!/usr/bin/env pwsh . /opt/idssys/powerwall/settings.ps1 -# Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null Connect-VIServer -Force -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null -Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} +$vms=Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI*'} Foreach ($vm in $vms) { $migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Relocate*' -and $_.State -eq 'Running'}