$vmhost="10.20.2.13" #esxi host
$namestart="YG191-VM"
$template="hk-vsan1-temp"
$datastore="vsan1"
$ipstart="10.11.40."
$endipscope=1..27

#循环生成虚拟机
foreach ($endip in $endipscope)
{  
    $ip=$ipstart+$endip
    $name=$namestart+$endip

    New-vm -vmhost $vmhost -Name $name -Template $template -Datastore $datastore
}