$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 }
时间: 2024-10-26 07:54:50