VMware Cloud Community
Koecerion
Contributor
Contributor
Jump to solution

Using PowerCLI to collect CreatedOn Dates

I am trying to update an inventory database and one thing that I cannot seem to get is the creation date of a VM and who created the VM. I have a PowerCLI script to obtain other information; Name, host, IP, cpu count, RAM count, etc.

Now, I wouldn't have a problem running this command: Get-VIEvent -maxsamples 10000 -Start (Get-Date).AddDays(-5) | where {$_.Gettype().Name -eq "VmCreatedEvent" -or $_.Gettype().Name -eq "VmBeingClonedEvent"}  Except, the database is out of date by 6 months and I would run out of memory on any machine running the command with -maxsamples [int]::MaxValue and .AddDays(-180). Is there a way I could query the VC DB to find this information and export the information to a CSV?

Any help would be greatly appreciated. Thanks!

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try using my Get-VIEventPlus function instead of the Get-VIEvent cmdlet.

It does the filtering on the vCenter, not on your station.

See Get the vMotion/svMotion history


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

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try using my Get-VIEventPlus function instead of the Get-VIEvent cmdlet.

It does the filtering on the vCenter, not on your station.

See Get the vMotion/svMotion history


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

Reply
0 Kudos
Koecerion
Contributor
Contributor
Jump to solution

Thanks LucD. This looks like exactly what I need.

Reply
0 Kudos
Koecerion
Contributor
Contributor
Jump to solution

Actually, Quick question.

Since the Get-MotionHistory function returns vMotion and svMotion events, can I change that to get "VmCreatedEvent" or "VmBeingClonedEvent" types by changing the $eventtypes variable?

EDIT: the -eventtypes parameter to Get-VIEventplus handles this. Got It.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Great, as you noticed you have enough with only the Get-VIEventPlus function.

The other one is just an example. There is another example in HA VM failover tracking

There is a lot of info to be got in the events :smileycool:


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