@@ -224,6 +224,12 @@ function New-VagrantVMXML {
224224 [string ] $SourcePath ,
225225 [parameter (Mandatory = $false )]
226226 [bool ] $LinkedClone = $false ,
227+ [parameter (Mandatory = $false )]
228+ [int ] $Memory = $null ,
229+ [parameter (Mandatory = $false )]
230+ [int ] $MaxMemory = $null ,
231+ [parameter (Mandatory = $false )]
232+ [int ] $CPUCount = $null ,
227233 [parameter (Mandatory = $false )]
228234 [string ] $VMName
229235 )
@@ -327,7 +333,11 @@ function New-VagrantVMXML {
327333
328334 # Apply original VM configuration to new VM instance
329335
330- $processors = $VMConfig.configuration.settings.processors.count ." #text"
336+ if ($CPUCount -ne $null ) {
337+ $processors = $CPUCount
338+ } else {
339+ $processors = $VMConfig.configuration.settings.processors.count ." #text"
340+ }
331341 $notes = (Select-Xml - XML $VMConfig - XPath " //notes" ).node." #text"
332342 $memory = (Select-Xml - XML $VMConfig - XPath " //memory" ).node.Bank
333343 if ($memory.dynamic_memory_enabled ." #text" -eq " True" ) {
@@ -336,10 +346,22 @@ function New-VagrantVMXML {
336346 else {
337347 $dynamicmemory = $False
338348 }
339- # Memory values need to be in bytes
340- $MemoryMaximumBytes = ($memory.limit ." #text" -as [int ]) * 1 MB
341- $MemoryStartupBytes = ($memory.size ." #text" -as [int ]) * 1 MB
342- $MemoryMinimumBytes = ($memory.reservation ." #text" -as [int ]) * 1 MB
349+
350+
351+ if ($Memory -ne $null ) {
352+ $MemoryMaximumBytes = $Memory * 1 MB
353+ $MemoryStartupBytes = $Memory * 1 MB
354+ $MemoryMinimumBytes = $Memory * 1 MB
355+ } 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
359+ }
360+
361+ if ($MaxMemory -ne $null ) {
362+ $dynamicmemory = $true
363+ $MemoryMaximumBytes = $MaxMemory * 1 MB
364+ }
343365
344366 $Config = @ {
345367 ProcessorCount = $processors ;
0 commit comments