Hyper-V批量创建虚拟机
Function MyNewVM($vmItem){ $VHDPath="D:\Hyper-V\vhd-sys-guest\sys-guest-" + $vmItem.GuestName + ".vhdx" New-VHD -Path $VHDPath -ParentPath $vmItem.VhdParentPath $VMLOC="D:\Hyper-V\vm\" New-VM -Name $vmItem.GuestName -Generation 2 -Path $VMLOC -MemoryStartupBytes $vmItem.MemoryStartupBytes -VHDPath $VHDPath -SwitchName $vmItem.SwitchName Set-VMMemory -VMName $vmItem.GuestName -DynamicMemoryEnabled 1 -MinimumBytes $vmItem.MemoryMinimumBytes -MaximumBytes $vmItem.MemoryMaximumBytes Set-VMProcessor -VMName $vmItem.GuestName -Count $vmItem.ProcessorCount -ExposeVirtualizationExtensions $true -Maximum $vmItem.ProcessorMaximum } $vmItem=@{} $vmItem.VhdParentPath="D:\Hyper-V\vhd-sys-tpl\sys-win2012r2-chia-20210501-1.vhdx" $vmItem.SwitchName="wan" $vmItem.MemoryStartupBytes = 4GB#启动内存 $vmItem.MemoryMinimumBytes = 4GB#最低内存 $vmItem.MemoryMaximumBytes = 32GB#最大内存 $vmItem.ProcessorCount = 48#CPU核心数 $vmItem.ProcessorMaximum = 100#CPU限制 for ($i=31; $i -le 40;$i++) { $vmItem.GuestName="jbx-chia-" + $i MyNewVM($vmItem) }