WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / VMware Cloud on AWS - VM Creation Date available in vSphere API

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

10.23.2017 by William Lam // 2 Comments

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:

  • Using vSphere SDK for Perl to query for VM Creation Dates
  • Using PowerCLI to query for VM Creation/Deletion Dates
  • Using vSphere SDK for Perl to update VM Custom Field with VM Creation Date

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?

More from my site

  • VM Creation Date now available in vSphere 6.7
  • VMware Cloud (VMC) Console Inventory with various vSphere "Linked Modes"
  • Custom vCenter Server Role using vSphere Terraform Provider on VMware Cloud on AWS
  • Quick Tip - How to check if vSAN TRIM/UNMAP is enabled in VMware Cloud on AWS Cluster?
  • Using vCenter Converter 6.3 with vSphere 8 or VMware Cloud on AWS (VMC-A)

Categories // Automation, PowerCLI, VMware Cloud on AWS Tags // create date, createDate, virtual machine, VMware Cloud on AWS

Comments

  1. *protectedRonny says

    02/02/2018 at 6:32 am

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

    cheers,

    Ronny

    Reply
  2. *protectedRanganath Chenna says

    02/12/2018 at 7:37 am

    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 ?

    Reply

Leave a Reply to RonnyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...