VMware Cloud Community
jithinraj
Contributor
Contributor

How to List a powered off VMs for specific period

Hi All,

Can anyone please let me know how to list the powered off VMs from vCenter  for specific period using PowerCLI.

Thanks in advance…

-Jithin

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Try something like this

$vms = Get-VM 
Get-VIEvent
-Start (Get-Date).AddDays(-7) -Entity $vms -MaxSamples [int]::MaxValue | where{$_.FullFormattedMessage -like "*is powered off"} | Select @{N="VM";E={$_.vm.Name}},CreatedTime

It will look at the poweroff events for the last 7 days.

You can update the time range by updating the Start parameter and adding a Finish parameter.


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

Reply
0 Kudos
jithinraj
Contributor
Contributor

Thanks, let me try and get back to you...

Thanks

Jithin

Reply
0 Kudos