thisischristia1
Contributor
Contributor

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

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

0 Kudos
3 Replies
LucD
Leadership
Leadership

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

0 Kudos
thisischristia1
Contributor
Contributor

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

0 Kudos
thisischristia1
Contributor
Contributor

Correction, looks like I am getting output now. Thanks

0 Kudos