VMware Cloud Community
sc_21111
Enthusiast
Enthusiast
Jump to solution

Getting events details in out-gridview

Hello

I'm using the following command to extract events from vcenter

Get-VIEvent -Start (Get-Date 03/07/2024) -Finish (Get-Date 03/08/2024) | ?{$_.FullFormattedMessage -like "*DSVM*" } | Out-GridView

But many columns shows a generic *Argument text instead of the real value.

How can I extract the corresponding value, the Datacenter compute resource and so on ?

sc_21111_0-1710317683673.png

 

Labels (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is because those properties are themselves objects with multiple properties.
And the PS output engine doesn't know how to display them.

You have to look at the Event object, and all it's derived objects, and then use a Select-Object with a calculated property to get the actual values you want in the output.
The Datacenter object contains a property Datacenter that itself has a MoRef, a pointer to the actual Datacenter object.
Use the Get-View cmdlet to get the actual object.

For example

Get-VIEvent -Start (Get-Date 03/07/2024) -Finish (Get-Date 03/08/2024) | 
Where{$_.FullFormattedMessage -like "*DSVM*" } | 
Select UserName, @{N='Datacenter';E={(Get-View -Id $_.Datacenter.Datacenter -Property Name).Name}} |
Out-GridView

 


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

That is because those properties are themselves objects with multiple properties.
And the PS output engine doesn't know how to display them.

You have to look at the Event object, and all it's derived objects, and then use a Select-Object with a calculated property to get the actual values you want in the output.
The Datacenter object contains a property Datacenter that itself has a MoRef, a pointer to the actual Datacenter object.
Use the Get-View cmdlet to get the actual object.

For example

Get-VIEvent -Start (Get-Date 03/07/2024) -Finish (Get-Date 03/08/2024) | 
Where{$_.FullFormattedMessage -like "*DSVM*" } | 
Select UserName, @{N='Datacenter';E={(Get-View -Id $_.Datacenter.Datacenter -Property Name).Name}} |
Out-GridView

 


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

sc_21111
Enthusiast
Enthusiast
Jump to solution

Hello @LucD  

thanks for the help

 

0 Kudos