From 9c1ab2bd9f4e7943cae79a5e5c5f68257e5ac488 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 4 Oct 2018 15:16:58 -0700 Subject: [PATCH] Wrap automatic checkpoint enable to prevent inadvertent execution --- plugins/providers/hyperv/scripts/configure_vm.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/providers/hyperv/scripts/configure_vm.ps1 b/plugins/providers/hyperv/scripts/configure_vm.ps1 index 023993270..32e6c8b0b 100644 --- a/plugins/providers/hyperv/scripts/configure_vm.ps1 +++ b/plugins/providers/hyperv/scripts/configure_vm.ps1 @@ -106,12 +106,14 @@ if($EnableAutomaticCheckpoints) { } try { - if($autochecks -eq 1 -and (Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -eq $null) { - Write-ErrorMessage "AutomaticCheckpointsEnabled is not available" - exit 1 + if((Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -eq $null) { + if($autochecks -eq 1) { + Write-ErrorMessage "AutomaticCheckpointsEnabled is not available" + exit 1 + } + } else { + Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks } - - Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks } catch { Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}" exit 1