$vms = Import-CSV D:\newvm\NewVMs.csv
$netmask = "255.255.255.0"
$gateway = "192.168.206.254"
$dns = "192.168.161.203"
$custSysprep = Get-OSCustomizationSpec -Name "Linux"
$ResourcePool = Get-ResourcePool -Name "vmpool"
$Datastore = Get-DatastoreCluster -Name "Cluster01"
$Template = Get-Template -Name "centos_linux_v6_v1"
$network = Get-VirtualPortGroup -Name "portgroup100"
foreach ($vm in $vms){
$custSysprep `
| Get-OSCustomizationNicMapping `
| Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $vm.ip -SubnetMask $netmask -DefaultGateway $gateway
New-VM -Name $vm.name -OSCustomizationSpec $custSysprep -Template $Template -ResourcePool $ResourcePool -Datastore $Datastore -RunAsync
}本文出自 “汜水流年_” 博客,请务必保留此出处http://timefiles.blog.51cto.com/8475652/1957079
原文:http://timefiles.blog.51cto.com/8475652/1957079