Automation

 View Only
  • 1.  How to print seconds from Get-VIEvent?

    Posted Jan 14, 2021 10:51 PM

    We're trying to track snapshot consolidation times on some VMs and when I look on the VSphere web console I get full timestamps such as "01/14/2021, 1:19:17 AM" for snapshot deleted and "01/14/2021, 1:19:33 AM" for virtual disk consolidation succeeded.

    Unfortunately, when I pull the same entity using Get-VIEvent all I have for the CreatedTime field for both entries is "1/14/2021 1:19" without the seconds. Clearly there must be some flag or parameter I can use to get the complete timestamp, right?



  • 2.  RE: How to print seconds from Get-VIEvent?

    Posted Jan 15, 2021 06:22 AM

    That is caused by the default format for the objects returned by Get-VIEvent.
    The property is a DateTime object, so you have access.
    It just requires a calculated property.
    For example



  • 3.  RE: How to print seconds from Get-VIEvent?

    Posted Jan 15, 2021 07:26 PM

    This is really good, thanks! Now I just need to tie this in with what I'm currently trying to do, which goes like this:

    So far I've integrated your suggestion as follows, but it only returns the timestamps:

    What I need is the VM Name, and (associated by ChainId I think) the Task: Remove snapshot and linked "Virtual machine foobar disks consolidated successfully" from FullFormattedMessages.

    I can live with the output as in the first one-liner and grind up the data in Excel but I'm always open to a better way.



  • 4.  RE: How to print seconds from Get-VIEvent?

    Posted Jan 15, 2021 07:35 PM

    You could do something like this