diff --git a/plugins/providers/hyperv/action/import.rb b/plugins/providers/hyperv/action/import.rb index 548dbdc39..d841242ff 100644 --- a/plugins/providers/hyperv/action/import.rb +++ b/plugins/providers/hyperv/action/import.rb @@ -38,18 +38,18 @@ module VagrantPlugins config_type = nil vm_dir.each_child do |f| if f.extname.downcase == '.xml' + @logger.debug("Found XML config...") config_path = f config_type = 'xml' break end end - # Only check for .vmcx if there is no XML found to not - # risk breaking older vagrant boxes that added an XML - # file manually - if config_type == nil + vmcx_support = env[:machine].provider.driver.execute("has_vmcx_support.ps1", {}) + if vmcx_support vm_dir.each_child do |f| if f.extname.downcase == '.vmcx' + @logger.debug("Found VMCX config and support...") config_path = f config_type = 'vmcx' break diff --git a/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 b/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 new file mode 100644 index 000000000..79dac42d7 --- /dev/null +++ b/plugins/providers/hyperv/scripts/has_vmcx_support.ps1 @@ -0,0 +1,11 @@ +# Include the following modules +$Dir = Split-Path $script:MyInvocation.MyCommand.Path +. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1")) + +# Windows version 10 and up have support for binary format +$check = [System.Environment]::OSVersion.Version.Major -ge 10 +$result = @{ + result = $check +} + +Write-Output-Message $(ConvertTo-Json $result)