Update offsite-vm-shutdown.ps1

This commit is contained in:
2024-02-05 22:49:36 -06:00
parent 75f291b86c
commit 487dcf861e

View File

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