Automation

 View Only
  • 1.  Selecting specific value of a property

    Posted Aug 17, 2016 09:15 AM

    Get-VIEvent -Start (Get-Date).AddHours(-14) -MaxSamples ([int]::MaxValue) |

    where {$_.GetType().Name -eq "TaskEvent"}

    Lists all TaskEvents from the last 14 hours - good

    However, I want to select date/time, message and VM name

    date/time and message no problem just:

    select CreatedTime, FullFormattedMessage

    No idea how to get VM name so I can export this lot into a CSV.  VM name is a value (what is this called? Property attribute?) within the VM property of the Get-VIEvent object.  I just don't know how to extrapolate this particular single piece of a property into my output.  If I wanted just the name with no other info then:

    select -ExpandProperty Vm

    would work fine but I want the name alongside date/time and message.

    Help please!



  • 2.  RE: Selecting specific value of a property
    Best Answer

    Posted Aug 17, 2016 09:40 AM

    Try like this, it uses a calculated property to fetch the entityname from the TaskInfo object

    Get-VIEvent -Start (Get-Date).AddHours(-14) -MaxSamples ([int]::MaxValue) |

    where {$_.GetType().Name -eq "TaskEvent"} |

    Select CreatedTime, FullFormattedMessage,@{N='Entity';E={$_.Info.EntityName}}



  • 3.  RE: Selecting specific value of a property

    Posted Aug 17, 2016 10:45 AM

    LucD, the legend, thanks!