Always ensure full path to configuration file on import

This commit is contained in:
Chris Roberts 2018-06-15 07:48:14 -07:00
parent 694104b005
commit 8fbf27772a
1 changed files with 7 additions and 1 deletions

View File

@ -352,7 +352,13 @@ function Error-VagrantVMImport {
)
$ManagementService = Get-WmiObject -Namespace 'root\virtualization\v2' -Class 'Msvm_VirtualSystemManagementService'
$Result = $ManagementService.ImportSystemDefinition($VMConfigFile, $null, $true)
# Relative path names will fail when attempting to import a system
# definition so always ensure we are using the full path to the
# configuration file.
$FullPathFile = (Resolve-Path $VMConfigFile).Path
$Result = $ManagementService.ImportSystemDefinition($FullPathFile, $null, $true)
if($Result.ReturnValue -eq 0) {
throw "Unknown error encountered while importing VM"
} elseif($Result.ReturnValue -eq 4096) {