@@ -333,32 +333,32 @@ function New-VagrantVMXML {
333333
334334 # Apply original VM configuration to new VM instance
335335
336- if ($CPUCount -ne $null ) {
336+ if ($CPUCount -ne $null -and $CPUCount -gt 0 ) {
337337 $processors = $CPUCount
338338 } else {
339339 $processors = $VMConfig.configuration.settings.processors.count ." #text"
340340 }
341341 $notes = (Select-Xml - XML $VMConfig - XPath " //notes" ).node." #text"
342- $memory = (Select-Xml - XML $VMConfig - XPath " //memory" ).node.Bank
343- if ($memory .dynamic_memory_enabled ." #text" -eq " True" ) {
342+ $memoryNode = (Select-Xml - XML $VMConfig - XPath " //memory" ).node.bank
343+ if ($memoryNode .dynamic_memory_enabled ." #text" -eq " True" ) {
344344 $dynamicmemory = $True
345345 }
346346 else {
347347 $dynamicmemory = $False
348348 }
349349
350350
351- if ($Memory -ne $null ) {
351+ if ($Memory -ne $null -and $Memory -gt 0 ) {
352352 $MemoryMaximumBytes = $Memory * 1 MB
353353 $MemoryStartupBytes = $Memory * 1 MB
354354 $MemoryMinimumBytes = $Memory * 1 MB
355355 } else {
356- $MemoryMaximumBytes = ($memory .limit ." #text" -as [int ]) * 1 MB
357- $MemoryStartupBytes = ($memory .size ." #text" -as [int ]) * 1 MB
358- $MemoryMinimumBytes = ($memory .reservation ." #text" -as [int ]) * 1 MB
356+ $MemoryMaximumBytes = ($memoryNode .limit ." #text" -as [int ]) * 1 MB
357+ $MemoryStartupBytes = ($memoryNode .size ." #text" -as [int ]) * 1 MB
358+ $MemoryMinimumBytes = ($memoryNode .reservation ." #text" -as [int ]) * 1 MB
359359 }
360360
361- if ($MaxMemory -ne $null ) {
361+ if ($MaxMemory -ne $null -and $MaxMemory -gt 0 ) {
362362 $dynamicmemory = $true
363363 $MemoryMaximumBytes = $MaxMemory * 1 MB
364364 }
0 commit comments