$prefixVMName = "Server2IO-" $basePath1 = "f:\VM\" $basePath2 = "g:\VM\" $parentHDDPath1 = "E:\Master\Windows server 2019 Master.vhdx" $parentHDDPath2 = "E:\Master\Windows server 2019 Master.vhdx" $MACs = @("00-15-5d-01-80-00","00-15-5d-01-80-01","00-15-5d-01-80-02","00-15-5d-01-80-03","00-15-5d-01-80-04", "00-15-5d-01-80-05","00-15-5d-01-80-06","00-15-5d-01-80-07","00-15-5d-01-80-08","00-15-5d-01-80-09", "00-15-5d-01-80-0a","00-15-5d-01-80-0b","00-15-5d-01-80-0c","00-15-5d-01-80-0d","00-15-5d-01-80-0e", "00-15-5d-01-80-0f","00-15-5d-01-80-10","00-15-5d-01-80-11","00-15-5d-01-80-12","00-15-5d-01-80-13", "00-15-5d-01-80-14","00-15-5d-01-80-15","00-15-5d-01-80-16","00-15-5d-01-80-17","00-15-5d-01-80-18") $stevec = 0 foreach ($MAC in $MACs) { if($stevec -le 9) { $VMName = $prefixVMName + "0" + $stevec } else { $VMName = $prefixVMName + $stevec } if($stevec %2 -eq 0) { $basePath = $basePath1 $parentHDDPath = $parentHDDPath1 } else { $basePath = $basePath2 $parentHDDPath = $parentHDDPath2 } $path = $basePath + $prefixVMName + '\' + $VMName + '.vhdx' New-VM -Name $VMName -MemoryStartupBytes 2048MB -Generation 2 -SwitchName "Virtual Switch" -Path ($basePath + $prefixVMName) -Verbose SET-VMProcessor –VMName $VMName –Count 4 New-VHD -ParentPath $parentHDDPath -Path $path -Differencing Add-VMHardDiskDrive $VMName -Path $path Set-VMNetworkAdapterVlan -VMName $VMName -Access -VlanId 2 Set-VMNetworkAdapter -VMName $VMName -StaticMacAddress $MAC $BootHDD = Get-VMHardDiskDrive $VMName Set-VMFirmware -VMName $VMName -FirstBootDevice $bootHDD Set-VMProcessor -VMName $VMName -ExposeVirtualizationExtensions $true Get-VMNetworkAdapter -VMName $VMName | Set-VMNetworkAdapter -MacAddressSpoofing On $stevec++ } New-VMSwitch -Name "Virtual Switch" -NetAdapterName "NIC-Team" -AllowManagementOS $false -MinimumBandwidthMode Weight Set-VMSwitch -Name "Virtual Switch" -DefaultFlowMinimumBandwidthWeight 100 Add-VMNetworkAdapter -ManagementOS -Name Host -SwitchName "Virtual Switch" Add-VMNetworkAdapter -ManagementOS -Name "Live Migration" -SwitchName "Virtual Switch" Set-VMNetworkAdapter -ManagementOS -Name Host -MinimumBandwidthWeight 25 Set-VMNetworkAdapter -ManagementOS -Name "Live Migration" -MinimumBandwidthWeight 25 Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName Host -Access -VlanId 2 Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName "Live Migration" -Access -VlanId 2