foreach ($vm in $vms){ $name = $vm.Name $cpu = $vm.NumCPU $mem = $vm.MemoryGB $disk = $vm.DiskGB $note = $vm.Description $network = Get-VirtualPortGroup -Name Vlan1207 Set-VM -VM $name -MemoryGB $mem -NumCpu $cpu -Notes $note Get-VM -Name $name | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $network -Confirm:$false Get-VMResourceConfiguration -vm $name | Set-VMResourceConfiguration -CpuReservationMhz 576 -MemReservationGB 8 -Confirm:$false get-vm -Name $name | Start-VM -Confirm:$false -RunAsync if ([int]$disk -gt "101"){ New-HardDisk -VM $name -CapacityGB $disk -StorageFormat Thin -Confirm:$false } }
转载于:https://blog.51cto.com/timefiles/1886931