Work Smart, not Hard – Automate Custom Attributes

I’m not sure how widely vCenter custom attributes are used in general, but I certainly find them useful for a summary of important information in a single view (the VM summary tab). The only problem with using additional annotations, is that the data only becomes useful if it is maintained and can be relied upon.

So with this in mind I am setting out to create a series of workflows which will automatically populate these values without any manual intervention. From the custom attributes that I use there are two sources of information (vCenter and a MSSQL database). This post will cover the vCenter data, and a future one will cover the SQL data.

Since I use fully automated HA/DRS clusters including storage DRS I want to know (from the summary tab) which datastore the VM is located on. Yes, I know which cluster it’s on but I cant see the actual datastore without going to the maps or storage views tab.

In addition to this requirement, I want to know which resource pool the VM is located in (in the case of newly provisioned systems, or an admin simply moving the VM to a different pool).

So my requirements are simple;

I want a single summary view of reliable data.

I want the values updated dynamically without manual intervention.

Here is an example of the custom annotations that I use;

For the first stage, I am going to create a PowerCLI script which will be executed on a set schedule. This will query vCenter, and then update the values for all the VM’s in scope.

Here is the script, just remember to change the highlighted rows to suite your own environment;

For the other custom attributes that I need to fetch from a SQL database I am currently using a ODBC data connection to build up the PowerShell code in MS-Excel which can then be refreshed on demand, copied and pasted ready for execution.

So although this works, it’s a manual process and I want to automate this fully … but that will be in a follow up post once I have written the script and tested the process.