Add-PSSnapin *vmware* $passwd = Read-Host "input your vcenter password: " -AsSecureString Connect-VIServer -Server 10.10.10.10 -User [email protected] -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 }
时间: 2024-10-11 14:24:12