To resize VMs using PowerShell with PowerCLI from a csv list, first install the software:
https://my.vmware.com/web/vmware/details?downloadGroup=PCLI650R1&productId=614
Then create a list of servers to resize and save it as a CSV file in C:\temp\VMs.csv:
1 2 3 4 5 |
Server01 Server02 Server03 |
Save the below as Something.PS1 and run from PowerCLI
Note: Change VCENTRE to your vCentre, this script will TURN THE SERVER OFF then give each VM two CPUs, one socket and 5GBs of RAM.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$me = Get-Credential connect-viserver "VCENTRE" -User $me $vms = get-content C:\Temp\VMs.csv ForEach ($vm in $vms){ $vms | Shutdown-VMGuest –Confirm:$False Sleep 60 $vms | Set-VM –MemoryGB 8 –NumCpu 2 –Confirm:$False $vms | Start-VM } |
Leave a Reply