VMware Cloud Community
domrein
Contributor
Contributor
Jump to solution

Orchestrator get create date of VM

Hi all,

is there a way to get the create Date from the Javascript VCVirtualMachine object?

With PowerCLI you can do this very simple via $vm.CreateDate ($vm from Get-VM) - is there anything similar?

Thanks!

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

You can get creation time from vCenter events for the VM. Try the following sample code:

var spec = new VcEventFilterSpec(); 

spec.eventTypeId = ["VmCreatedEvent"]; 

spec.entity = new VcEventFilterSpecByEntity(); 

spec.entity.entity = vm; 

spec.entity.recursion = VcEventFilterSpecRecursionOption.self; 

var events = vm.sdkConnection.eventManager.queryEvents(spec);

if (events != null && events.length > 0) {

    System.log("Created on: " + events[0].createdTime);

}

Another option for environments with latest vCenter / ESXi is to check if the property vm.config.createDate is set.

View solution in original post

0 Kudos
2 Replies
daphnissov
Immortal
Immortal
Jump to solution

This is a vRO question so should be moved to that area.

0 Kudos
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi,

You can get creation time from vCenter events for the VM. Try the following sample code:

var spec = new VcEventFilterSpec(); 

spec.eventTypeId = ["VmCreatedEvent"]; 

spec.entity = new VcEventFilterSpecByEntity(); 

spec.entity.entity = vm; 

spec.entity.recursion = VcEventFilterSpecRecursionOption.self; 

var events = vm.sdkConnection.eventManager.queryEvents(spec);

if (events != null && events.length > 0) {

    System.log("Created on: " + events[0].createdTime);

}

Another option for environments with latest vCenter / ESXi is to check if the property vm.config.createDate is set.

0 Kudos