VMware Cloud Community
Pilu1978
Enthusiast
Enthusiast
Jump to solution

VM deployed or Removed

Is there any other way to determine the number of VMs deployed or removed in a cluster in a week rather than using vmcreatedevent and vmremovedevent as it is not giving me accurate results.

Any help would be appreciated.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

In the event you can find the clustername under ComputeResource.Name


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

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

You're probably not looking at all the related events.

There are also VmClonedEvent, VmRegisteredEvent...

Which methods do you use to create and remove VMs ?

How far off are the figures you get with what you know was created and removed ?


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

0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Thanks for your update. I am using the follwing code currently:

$VIEvent = Get-VIEvent -maxsamples 1000000 -Start (Get-Date).AddDays(-7) -Finish (Get-Date)

$vmcreated =  @($VIEvent | where {$_.Gettype().Name -eq "VmCreatedEvent" -or $_.Gettype().Name -eq "VmBeingClonedEvent" -or $_.Gettype().Name -eq "VmBeingDeployedEvent"})

$vmdeleted =  @($VIEvent | where {$_.Gettype().Name -eq "VmRemovedEvent"})

But it is not giving me accurate results.

Please let me know if I am doing anything wrong.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you're running the script against a busy vCenter, the number 1000000 might not be big enough.

It's better to use the maximum value you can pass on that parameter.

Does this produce more accurate results ?

$VIEvent = Get-VIEvent -maxsamples ([int]::MaxValue) -Start (Get-Date).AddDays(-7)

$createEvents = "VmCreatedEvent","VmClonedEvent","VmDeployedEvent"
$vmcreated =  @($VIEvent | where {$createEvents -contains $_.Gettype().Name})
$vmdeleted =  @($VIEvent | where {$_.Gettype().Name -eq "VmRemovedEvent"})


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

0 Kudos
Pilu1978
Enthusiast
Enthusiast
Jump to solution

Thanks. I will try and let you know. One more thing.

How to segregate this events so that we can determine the numbers cluster wise.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

In the event you can find the clustername under ComputeResource.Name


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

0 Kudos