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){ $cpu = $vm.NumCPU $mem = $vm.MemoryGB $disk = $vm.DiskGB $note = $vm.Description $network = $vm.NetworkName get-vm -Name $vm.Name | Set-VM -NumCpu $cpu -MemoryGB $mem -Notes $note -RunAsync } $vms = Import-CSV E:\NewVMs.csv foreach ($vm in $vms){ $disk = $vm.DiskGB Get-VM -Name $vm.Name | Get-HardDisk | Set-HardDisk -CapacityGB $disk } $vms = Import-CSV E:\NewVMs.csv foreach ($vm in $vms){ $net = $vm.NetworkName Get-VM -Name $vm.Name | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $net -RunAsync }
时间: 2024-12-23 00:35:14