批量创建HyperV虚拟机--Windows 2012已验证

$HyperVRootPath="C:\"
$NodeName="SQL2014Node0"
$FlagVM=3
$NetworkName="Local"
$LogicPrecesserCount=8
$MomeryCount=2GB
$MasterDiskPath="D:\Windows2008R2SP1Master.vhdx"
$NodeNameFullName=""
$VMName=""
for($i=1;$i -le $FlagVM;$i++){
$FolderPath = $HyperVRootPath + $NodeName + $i
#Create VM Sub-Folder
mkdir $FolderPath
#Create VM Disk
$NodeNameFullName = $NodeName + $i + ".vhdx"
$VMNodePath = $FolderPath + "\" + $NodeNameFullName
Write-Host $VMNodePath
New-VHD �CParentPath $MasterDiskPath �CPath $VMNodePath -Differencing
#Configure VM
$VMName = $NodeName + $i
New-VM �CName $NodeNameFullName �CMemoryStartupBytes $MomeryCount �CVHDPath $VMNodePath -SwitchName $NetworkName
Set-VMProcessor $NodeNameFullName -Count $LogicPrecesserCount
Set-VMNetworkAdapter $NodeNameFullName -RouterGuard On
#Start VM
Start-VM �CName $NodeNameFullName
}

 

你可能感兴趣的:(powershell,批量创建,HYPERV)