Select Page

Amend VM Specifications Via VMware PowerCLI

Script can be found at the bottom of this post. You will need to change the “vCenter Name” field to your vCenter address. You will need to save this as a .PS1

Script Pre-Warnings:

  • The Script has been configured to Shut down the VM’s Gracefully using VMware Tools, The List of VM’s will be all powered off, the changes will be made to the VM’s then the VM’s will all be powered on at once. Please be very careful as If this is misconfigured you could shut down the wrong VM’s resulting in an outage of those VM’s.
  • If VMware Tools Is not running on the VM it will not be able to Shut down the VM’s, This will result in a loop of the script. In this case I would advise powering off the VM’s via the Guest.
  • This script will amend Memory/CPU configuration. It will also enable Hot-Add for Memory/CPU so these can be amended in the future without having to power off the VM.
  • If you need to leave the memory exactly the same you will need to type the value that is currently is configured with on the VM.
  • If you receive an error about the Stop-VMGuest command you may need to amend this to Shutdown-VMGuest (I have amended the script to use Shutdown-VMGuest, but if you are using this on different vCenters it may complain that this command is retired, in which case you will need to change Shutdown-VMGuest to Stop-VMGuest)

Amend VM Script Snippet - Amend VM Specifications Via VMware PowerCLI

Instructions for Running Amend-VM Script:

  1. Login to machine with VMware PowerCLI Installed.
  2. Browse to C:\Temp\Input.csv – This will be the CSV that needs to be populated with the servers required.
  3. The script is configured to amend the cores per socket. So the CSV has to be populated in the following format:

So for example: 2 CPU 2 CORES = 1 Socket 2 Cores.

Amend VM Mem 2 CPU 2 - Amend VM Specifications Via VMware PowerCLI

4 CPU 2 CORES = 2 Socket 2 Cores.

Amend VM Mem 2 CPU 4 - Amend VM Specifications Via VMware PowerCLI

4 CPU 4 CORES = 1 Socket 4 Cores

Amend VM Mem 4 CPU 4 - Amend VM Specifications Via VMware PowerCLI

  1. When you have filled out the relevant information in the CSV You can now proceed to run the script. You may need to amend the vCenter name If you are planning on running this on different vCenters.
  2. Open PowerCLI and Point to the script location.
  3. When prompted fill out your VMware Account Details.
  4. Here is an example of the script in-flight:

Amend VM Script Running - Amend VM Specifications Via VMware PowerCLI

  1. You can now confirm the changes were successful by selecting ‘Edit Settings’ on the VM’s in question and confirming they now have the correct configuration.
  2. You can now disconnect the PowerCLI session. Alternatively you can stay connected and amend the Input.csv for a new list of VM’s.

Thanks for reading! Hopefully this will be useful!

Pin It on Pinterest

Share This