From 83ed01869d12152d63a0b9185d05edd65753bdde Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 13 Nov 2018 12:21:17 -0800 Subject: [PATCH] Ignore errors when generating new VM configuration The default error action is to stop. When generating the initial VM configuration during import, if the Compare-VM command fails it results in a generic error message. Instead the error should be ignored so the source VM can be inspected and a useful error message can be returned to the user. --- plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 index d277f4e9c..f130dc7de 100644 --- a/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 +++ b/plugins/providers/hyperv/scripts/utils/VagrantVM/VagrantVM.psm1 @@ -85,7 +85,7 @@ function New-VagrantVMVMCX { VhdDestinationPath = Join-Path $DataPath "Virtual Hard Disks"; VirtualMachinePath = $DataPath; } - $VMConfig = (Hyper-V\Compare-VM -Copy -GenerateNewID @NewVMConfig) + $VMConfig = (Hyper-V\Compare-VM -Copy -GenerateNewID @NewVMConfig -ErrorAction SilentlyContinue) # If the config is empty it means the import failed. Attempt to provide # context for failure