From 1f74aedeaab31f1136ad9a8d744d64a88f9083c4 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 5 Sep 2018 13:37:45 -0700 Subject: [PATCH] Check for automatic checkpoint support before configuring The AutomaticCheckpointsEnabled option may not always be available depending on the version in use. Check for support before applying the configured value. If automatic checkpoints are to be enabled and support is not available, force an error. --- plugins/providers/hyperv/scripts/configure_vm.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/providers/hyperv/scripts/configure_vm.ps1 b/plugins/providers/hyperv/scripts/configure_vm.ps1 index 54f878f25..023993270 100644 --- a/plugins/providers/hyperv/scripts/configure_vm.ps1 +++ b/plugins/providers/hyperv/scripts/configure_vm.ps1 @@ -106,6 +106,11 @@ 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 + } + Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks } catch { Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}"