VMware Cloud Community
nimos001
Enthusiast
Enthusiast

VMs Created Script run against vcenter

Guys,

I am not sure if I have found the correct forum or not. But I am struggling to get a report to show me "VmClonedEvent" outputs. I am using the below script as part of the vcheck and all other creation events show results except for any cloned VM's which make up 95% of all new VM's in our environment. Does anyone have any ideas what might be happening here?

# Start of Settings
# Set the number of days to show VMs created for
$VMsNewRemovedAge =30
# End of Settings
$VIEvent = Get-VIEvent -maxsamples 10000 -Start ($Date).AddDays(-$VMsNewRemovedAge)
$OutputCreatedVMs = @($VIEvent | where {$_.Gettype().Name -eq "VmBeingCreatedEvent" -or $_.Gettype().Name -eq "VmClonedEvent" -or $_.Gettype().Name -eq "VmBeingDeployedEvent"} | Select createdTime, UserName, fullFormattedMessage)
$OutputCreatedVMs
$Title = "Created or cloned VMs"
$Header =  "VMs Created or Cloned (Last $VMsNewRemovedAge Day(s)): $(@($OutputCreatedVMs).count)"
$Comments = "The following VMs have been created over the last $($VMsNewRemovedAge) Days"
$Display = "Table"
$Author = "Alan Renouf"
$PluginVersion = 1.1
$PluginCategory = "vSphere"
Reply
0 Kudos
4 Replies
nimos001
Enthusiast
Enthusiast

Okay, it looks like it does in fact return 'cloned' creations, but I think the problem is that I can't seen to go back more than 3 or 4 days. I am not aware of any DB retention settings. Does anyone have any ideas why I am not able to pull events from farther back? I get maybe 25 results going back 30 days when I should have more like 70 or 80 results of newly created VM's.

Reply
0 Kudos
nimos001
Enthusiast
Enthusiast

maxsamples was my problem....

Reply
0 Kudos
nimos001
Enthusiast
Enthusiast

Does anyone know if there is a better way to pull the VM created events? My problem is that I have so many events in virtual center that it is a struggle to pull anything past 2 or 3 days without adjusting the maxsamples variable and the script in turn taking hours and hours to complete. Also I see that any 'cloned' VM's will not show the name of the new VM but instead will only show me the name of the system that was used for the base of the clone. Does that make sense?

Reply
0 Kudos
nimos001
Enthusiast
Enthusiast

I know I am just having a conversation with myself here, but I went ahead and just setup some SQL queries to pull what I needed. Thanks

Reply
0 Kudos