From b4a9f4a23b59e6e382385a2cf98f33aa9bbef6fa Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Mon, 23 Sep 2024 21:40:25 -0500 Subject: [PATCH] update --- esxi-scripts/host-vm-shutdown.ps1 | 2 +- esxi-scripts/offsite-host-shutdown.ps1 | 2 +- esxi-scripts/vm-shutdown.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esxi-scripts/host-vm-shutdown.ps1 b/esxi-scripts/host-vm-shutdown.ps1 index 78594c7e..62fc8dc3 100755 --- a/esxi-scripts/host-vm-shutdown.ps1 +++ b/esxi-scripts/host-vm-shutdown.ps1 @@ -6,7 +6,7 @@ Connect-VIServer -Force -Server $args[0] -Protocol https -User $ESXiUsername -Pa $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'} + $migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Migrate*' -and $_.State -eq 'Running'} if ([string]::IsNullOrEmpty($migrating)) { Get-VM $vm | Shutdown-VMGuest -Confirm:$false } diff --git a/esxi-scripts/offsite-host-shutdown.ps1 b/esxi-scripts/offsite-host-shutdown.ps1 index 4a3784af..16516ea4 100755 --- a/esxi-scripts/offsite-host-shutdown.ps1 +++ b/esxi-scripts/offsite-host-shutdown.ps1 @@ -8,7 +8,7 @@ Get-VM | Where {$_.PowerState -like '*On*'} | Shutdown-VMGuest -Confirm:$false # $vms=Get-VM | Where {$_.PowerState -like '*On*'} # 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'} +# $migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Migrate*' -and $_.State -eq 'Running'} # if ([string]::IsNullOrEmpty($migrating)) { # Get-VM $vm | Shutdown-VMGuest -Confirm:$false # } diff --git a/esxi-scripts/vm-shutdown.ps1 b/esxi-scripts/vm-shutdown.ps1 index 0af35066..07dcdf08 100755 --- a/esxi-scripts/vm-shutdown.ps1 +++ b/esxi-scripts/vm-shutdown.ps1 @@ -9,7 +9,7 @@ Foreach ($vmhost in $vmhosts) $vms=Get-VMHost | Where {$_.Name -eq $vmhost} | 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'} + $migrating=Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq $vm -and $_.Description -like '*Migrate*' -and $_.State -eq 'Running'} if ([string]::IsNullOrEmpty($migrating)) { Get-VM $vm | Shutdown-VMGuest -Confirm:$false }