How to know when VM was created

How to know when VM was created

book

Article ID: CTX489556

calendar_today

Updated On:

Description

Determine when a VM was created.


Instructions

Disclaimer: information displayed in commands are Citrix test server data.

There is a parameter in VM's property named "install-time", the time is in UTC .
[root@CH82 ~]# xe vm-list uuid=f1625e51-89d6-04c6-a540-8cf9b5f1577a params=name-label,install-time
name-label ( RW)      : Windows 10 (64-bit) (1)
    install-time ( RO): 20230321T06:08:35Z
Here is script to list VM installed within 30-days:
#!/bin/bash
uuid=$(xe vm-list params=uuid |awk '{print $5}' |awk 'NF')
vm_uuid=(${uuid})
for i in "${vm_uuid[@]}"; do

    install_time=$(xe vm-list uuid=$i params=install-time |awk '{print $5}'|sed 's/.$//' |awk 'NF')
    install_date=$(date -d "$install_time" -Iseconds)
    if [[ $(date -d "$install_date + 30 days" +%s) -ge $(date +%s) ]]; then
        xe vm-param-get uuid=$i param-name=name-label
    fi
done