I was recently doing some work with my VMware Cloud on AWS instance and I needed to verify something in the vSphere API. Since I already had a browser open, rather than context switch, I decided to quickly open up the vSphere MOB which is a debugging tool that provides a browser interface to the vSphere SOAP API. While going through the Virtual Machine view, I was pleasantly surprised to see a new VM config property called createDate which looks to give you the original date/time of when the VM was first created!

This is probably one of the most frequently asked question that I have seen from VI Admins around basic VM management and I am sure everyone has probably had a need to pull this type of information at least once in their career. Historically, VM creation date was not an easy thing to thing to find and success of retrieving that data was dependent on the retention of your vCenter Server Events database since that is where the information is stored. This means if you only retain 6 months worth of historical events, you will not be able to retrieve creation dates for VMs that were created prior to that.

Due to this constraint, most customers would have to go out their way to capture this information on initial deployment and either store that in a log file or persist that into their CMDB system. As a customer, I also took a similiar approach where I ended up storing the original provision date in our CMDB which can be consumed by our other internal tools. In addition, I also created a Custom Field for each VM where this information was also readily available which came in handy for quick reporting using the vSphere API.

Here are a few example scripts that demonstrate how you can retrieve VM Creation Dates in your current environment today:

So going back to our initial finding, if you are a VMware Cloud on AWS customer, when new VM is created using either the UI (Flex/H5) or API (PowerCLI, etc) the new createDate API property will automatically be populated with the creation date of the VM. As of right now, this property is only visible through the vSphere MOB as this property is not available in any of the existing vSphere SDKs including PowerCLI. However, if you wish to leverage this new property, I did put together a quick PowerShell/CLI script called VMCreationDate.ps1 which remotely calls into the vSphere MOB and parses out this value.

The script contains a function called Get-VMCreationDate which builds on top of the earlier work I had done using PowerShell to remotely invoke the vSphere MOB. You will need to first connect to VMWonAWS vCenter Server and then run the function which requires credential details along with the VM you wish to query. To make it easier to consume, you can simply create a few variables to store the vCenter Server hostname and credentials such as the following:

$vc_server = "FILL-ME-IN"
$vc_username = "FILL-ME-IN"
$vc_password = 'FILL-ME-IN'
$vmname = "FILL-ME-IN"

Next, we simply call our Connect-VIServer and the Get-VMCreationDate function to get the VM Creation Date like the following:

Connect-VIServer -Server $vc_server -User $vc_username -Password $vc_password
Get-VMCreationDate -vc_server $vc_server -vc_username $vc_username -vc_password $vc_password -vmname $vmname
Disconnect-VIServer -Server $vc_server -Confirm:$false

Here is a screenshot of running this against one of the VMs I had created earlier and we can see the CreateDate property:

Although this new API property is currently only available to VMware Cloud on AWS customers, hopefully it is a preview to what is to come in the future 🙂 I know I definitely would appreciate having such a field that is persistent with the life of the VM without relying on Events database, what do you think?

2 thoughts on “VMware Cloud on AWS - VM Creation Date available in vSphere API

  1. great news and thanks for sharing, William!
    I’d definitely like to have this property within vSphere as well.



  2. Hello William,

    We have a requirement to assign ‘VM Creation Date’ tag to all Virtual machines in vCenter using VMware Tags. Any leads how We can accomplish this ? My idea is to create multiple dates as Tags under Category ‘Date’ and assign tags to Virtual machines. But this may have 365 tags for every year. Do you have any alternate solution for this apart from this ?

Thanks for the comment!