VM Guest Customization in vCloud Director via PowerCLI

Bit of a quick post this, but hopefully useful to others.

I got asked recently if there was an easy way to set Guest Customization options for VMs hosted in vCloud Director via Powershell/PowerCLI. It turns out there is an extremely simple way, but the syntax is a bit awkward so figured it would make a good/quick blog post.

The Guest Customization settings are available as one of the ‘Section’ entries returned by accessing the ExtensionData properties on a CIVM object. Once connected (Connect-CIServer) you can see this from PowerCLI:

The ‘trick’ is that there are typically 5 sections (one each for OvfVSSD, OvfMsg, network connections, guest Customization and VMware tools). I’ve seen some approaches that rely on the ‘guest Customization’ setting always being found at the Section[3] index in the ExtensionData collection, but this could easily change in future and break any functionality relying on this. A much more reliable way of finding the guest Customization section values is:

But how about if you need to change/update a setting, luckily there is a method provided (UpdateServerData) which does exactly this. So if we want to (for example) change the ‘CustomizationScript’ setting to “echo “Hello World!” we can:

You can change other settings using the same method (e.g. ComputerName or Domain join settings).

Note that for many changes the VM must be powered off, and you may need to ‘Power On and Force Recustomization’ too.

As always, comments & feedback appreciated.


Tagged , , , . Bookmark the permalink.

5 Responses to VM Guest Customization in vCloud Director via PowerCLI

  1. Jonathan Culver says:

    Hi Jon

    Great post thanks. Is there any way of using this sort of approach to initiate a VMware Tools update from vCloud?

  2. Nico says:

    I just tried this out, and any changes that I make seem to take affect when I look at them via powershell, however those changes do not appear in the vCloud Director UI. When I powered cycle the vApp the settings that I had changed via powercli had reverted back to their original.

    What I’m looking to do is to change the VM Name and Computer name. Reason being is that I have a powershell script to automate the deployment of vApps using a template, but when I run the script the VM and Computer name (as well as any other guest customization options) are replicated from the template. I don’t see any option to set the vm or computer name when deploying a vApp template w/powercli.

    What am I missing?

    • Dave says:

      FWIW you might look at vcd cli, or ansible modules for vCloud Director. I’m doing Ansible and while the modules aren’t perfect, they certainly cover a lot of ground.

  3. Peter Veenbaas says:

    The links to your example images is not working – Getting error 404

    • Jon Waite says:

      Apologies for that – somewhere when moving hosting providers the links in this post got corrupted, have fixed now and will keep an eye out for others that have broken.

Leave a Reply

Your email address will not be published. Required fields are marked *

twenty − 8 =