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.
In the event you can find the clustername under ComputeResource.Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
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.
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
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.
In the event you can find the clustername under ComputeResource.Name
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference