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!
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}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD, the legend, thanks!