VMware Cloud Community
thisischristia1
Contributor
Contributor
Jump to solution

Get-VIEvent where "Task: Power off*" - No Output

So i am trying to generate a report of powered off VMs, but I want to run this report against VMs which have already been turned off and pull the data based on the task of powering a system off. The below code outputs no result. Any reason why?

get-vm | where {$_.powerstate -eq "PoweredOff"} |

Get-VIEvent | where {  $_.fullFormattedMessage -like "Task: Power off*" } |

select  createdTime, userName, FullformattedMessage,@{N="VM";E={$_.Vm.Name}} |

where {$_.createdtime -lt  (get-date).adddays(-1)}|

Export-Csv "C:\PowerState.csv" -NoTypeInformation -UseCulture

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

By default the Get-ViEvent cmdlet only returns 100 events.
either use the MaxSamples parameter or use the Start/Finish parameters

Get-VIEvent -MaxSamples ([int]::MaxValue) 


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

View solution in original post

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

By default the Get-ViEvent cmdlet only returns 100 events.
either use the MaxSamples parameter or use the Start/Finish parameters

Get-VIEvent -MaxSamples ([int]::MaxValue) 


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

Reply
0 Kudos
thisischristia1
Contributor
Contributor
Jump to solution

Added it, still no output. Initially without Max Samples it would not display anything.

Reply
0 Kudos
thisischristia1
Contributor
Contributor
Jump to solution

Correction, looks like I am getting output now. Thanks

Reply
0 Kudos