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
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
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
Added it, still no output. Initially without Max Samples it would not display anything.
Correction, looks like I am getting output now. Thanks