In a recent POC the customer had a special use case which I tackled singing vRealize Orchestrator and the Event Broker Service.

So, what was the use case?

Roll out a new Windows vSphere virtual machine using a custom hostname based on the machine type (Development=’dev0001‘, Test=’tst0001′, Production=’prd0001′, etc.). The hostname has to be the next available Computer Account in the Active Directory.

For example: a user requests a new Production machine and ‘prd1021′ is the latest Computer Account in the Active Directory, the new virtual machine will get hostname ‘prd1022′.

To accomplish this, I created a vRO workflow which will be used during vRA deployment of the VM triggered by the Event Broker.


Custom host name vRO workflow

The vRO workflow makes use of a custom property which needs to be added to vRA and can be used during request. Also an Active Directory server has to be registered with vRO.


The workflow performers the following tasks:

  1. Get VM property information from vRA;
  2. Get the custom property;
  3. Uses the custom property to search the Active Directory for the latest Computer Account;
  4. Determines the new hostname for the VM (latest Computer Account +1);
  5. Updates the initial VM hostname property used by vRA with the new hostname.

Download the workflow here and rename it to ‘EBS Host Rename.workflow’

Note: The script to search the Active Directory splits the hostname in a prefix and number. These have a fixed size in the script. In my case the prefix is 5 characters long and the number is 4 digits (total of 9). This can be changed in the script if needed.

var newComputerNameSuffix = lastComputerName.substring(5,9)
var MachinePrefix = lastComputerName.substring(0,5)

var SuffixNumber = Number(newComputerNameSuffix)
var nextNumber = SuffixNumber + 1

Configure the Event Broker and create a blueprint

Start the vRO client and import the Custom Hostname workflow.


Edit the workflow and add your vRA IaaS- and Active Directory server to the Attributes.


Save and Close the workflow.

Login to vRA and add a new custom property definition Make it available as a dropdown value during request. Under Predefined values you can add your VM naming convention related to machine type.



Create a new blueprint and give it a Name.


In the Properties tab add the Custom Property and select Show in Request.


Drag and drop a Network component and a vSphere Machine on the canvas. Edit the properties of the components according to your environment. If you want the machine to be automatically joined with the Domain, use/create a vSphere Customization specification which takes care of this.


Save the Blueprint and publish it.

Create a new Event Subscription to trigger the Custom Hostname workflow during request. Select Machine provisioning Topic.


Add the following Conditions:

  1. Blueprint name -> Equals -> ..yourblueprintname..
  2. Lifecycle State Name -> Equals -> VMPSMasterWorkflow32.Requested
  3. Lifecycle State Phase -> Equals -> EVENT


Select the Custom Hostname workflow.


Finish the Subscription and publish it.

Testing the workflow

First check your Active Directory for existing Computers Accounts.


Go to the Catalog and request the Blueprint using the Custom Hostname.


In my case I select Machine type Productie which determines the VM hostname prefix to be ‘wpzkh’.

The latest available Computer Account with prefix wpzkh is wpzkh1005. The new VM hostname provisioned by vRA should be ‘wpzkh1006‘. So let’s check this.

The workflow is being triggered. So the Event Subscription is working correctly.


The new Machine name is being updated by vRO and passed on to vRA. Under Managed Machines ‘wpzkh1006′ is visible.


Mission completed!

Note: Thanks to Adam Bohle for helping me out with the vRO piece.


Bio Dimitri de SwartDimitri

Dimitri is a CMP Specialist SE with VMware and therefor responsible for positioning and supporting vRealize Automation, Operations, Business and Code Stream at customers and partners.

He is a 15 year IT veteran who started as a system administrator and grew to be a senior infrastructure consultant at a large dutch hospital. He has a broad infrastructure, virtualization and VDI background and is experienced in pre-sales, consultancy, design and implementation of complex infrastructures.

Dimitri’s LinkedIn profile.