Add-PSSnapin *vmware* $passwd = Read-Host "input your vcenter password: " -AsSecureString Connect-VIServer -Server 10.10.10.10 -User administrator@vsphere.local -Password $passwd $vms = Import-CSV E:\NewVMs.csv foreach ($vm in $vms){ $Template = Get-Template $vm.template $VMHost = Get-VMHost $vm.Host $Datastore = Get-Datastore $vm.datastore $OSCustomization = Get-OSCustomizationSpec $vm.customization $ResourcePool = Get-ResourcePool $vm.ResourcePool New-VM -Name $vm.name -OSCustomizationSpec $OSCustomization -Template $Template -VMHost $VMHost -ResourcePool $ResourcePool -Datastore $Datastore -RunAsync }
原文地址:http://timefiles.blog.51cto.com/8475652/1886930