VMware Cloud Community
ewattnem
Contributor
Contributor
Jump to solution

How to retrieve Host name from Get-Vievent

I was wondering if someone could point me in a direction...

My code snippet is like this

      Get-VIevent –Maxsamples 100 -Server $physicalserver1 | Select-Object CreatedTime, host, fullformattedmessage

Which returns something like this...

   CreatedTime                    Host                                                  FullFormattedMessage
   -----------                            ----                                                    --------------------
   11/30/2020 3:25:06 PM    VMware.Vim.HostEventArgument    Lost access....

How do I show the hostname in the output instead of VMware.Vim.HostEventArgument?

Thanks for your help!

 

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use a calculated property.

Get-VIevent –Maxsamples 100 -Server $physicalserver1 | 
Select-Object CreatedTime, @{N='VMHost';E={$_.Host.Name}}, fullformattedmessage


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You can use a calculated property.

Get-VIevent –Maxsamples 100 -Server $physicalserver1 | 
Select-Object CreatedTime, @{N='VMHost';E={$_.Host.Name}}, fullformattedmessage


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ewattnem
Contributor
Contributor
Jump to solution

That worked perfect!  Thanks!!

0 Kudos