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!
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.
This is a vRO question so should be moved to that area.
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.