#宿主机为Server2012R2,基于母盘创建差异虚拟磁盘,二代虚拟机,动态内存。创建多台虚拟机请修改VMName后重复执行
$VMName = "s11"
$ParentVMPath = "D:"
$ParentVHDPath = "C:\VM\MotherVHD.vhdx"
$VmPath = $ParentVMPath + "\$VMName"
$VMVHDPath = $VmPath + "\Virtual Hard Disks"
New-Item $VMVHDPath -ItemType directory
New-VHD -ParentPath $ParentVHDPath -Path "$VMVHDPath\$VMName.vhdx" -Differencing
New-VM -Name "$VMName" -MemoryStartupBytes 3GB -Generation 2 -VHDPath "$VMVHDPath\$VMName.vhdx" -SwitchName "int88" -Path "$ParentVMPath"
Set-VM -Name $VMName -DynamicMemory -MemoryMinimumBytes 512MB -MemoryMaximumBytes 6GB -ProcessorCount 4
Add-VMDvdDrive -VMName $VMName
时间: 2024-11-19 23:14:40