VMware Cloud Community
ObibiniKwasi
Enthusiast
Enthusiast

Number of Vms created and Removed/Deleted in the past 12 Months

Hi Guys,

Anyone knows of any tool or script I can easily use to generate a report on the number of VMs that were created or removed in the past 12 months? PowerGui worked in the past but not anymore.

Regards,

Frank

0 Kudos
1 Reply
LucD
Leadership
Leadership

You can do something like this.

Note that this might take a bit of time, depending also on the number of events you keep in the DB.

$start = (Get-Date).AddMonths(-12)

$events = Get-VIEvent -Start $start -MaxSamples ([int]::MaxValue)

$events | where{$_ -is [VMware.Vim.VmCreatedEvent] -or $_ -is [VMware.Vim.VmRemovedEvent]} |

Group-Object -Property {$_.GetType()} | %{

  New-Object PSObject -Property @{

    Action = $_.Name.TrimStart('VMware.VimAutomation.Vm').TrimEnd('Event')

    Number = $_.Group.Count

  }

}


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

0 Kudos