From 0ea4dcdc6eae9cacb6c58254963cb34a2909a571 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 13 Nov 2018 13:04:11 -0800 Subject: [PATCH] Disable automatic checkpoints prior to VM removal --- plugins/providers/hyperv/scripts/delete_vm.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/providers/hyperv/scripts/delete_vm.ps1 b/plugins/providers/hyperv/scripts/delete_vm.ps1 index 18349b475..6e6b59bfa 100644 --- a/plugins/providers/hyperv/scripts/delete_vm.ps1 +++ b/plugins/providers/hyperv/scripts/delete_vm.ps1 @@ -9,6 +9,9 @@ $ErrorActionPreference = "Stop" try { $VM = Hyper-V\Get-VM -Id $VmId + if((Get-Command Hyper-V\Set-VM).Parameters["AutomaticCheckpointsEnabled"] -ne $null) { + Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $false -ErrorAction SilentlyContinue + } Hyper-V\Remove-VM $VM -Force } catch { Write-ErrorMessage "Failed to delete VM: ${PSItem}"