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.
This commit is contained in:
Chris Roberts 2018-11-13 12:21:17 -08:00
parent b2e682b0e3
commit 83ed01869d
1 changed files with 1 additions and 1 deletions

View File

@ -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