VMware Cloud Community
marvinb
Enthusiast
Enthusiast
Jump to solution

I am trying to come up with a script that will identify Newly created vms over the last week.

I did find a script, grabs all the events from the even log.  That assumes that the first even is the creation event.  This is not a valid assumption as we don't keep evens for very long.

I really just need to know when someone creates a new VM so we can properly on-board it.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-7) |

  where {$_ -is [VMware.Vim.VmCreatedEvent]}


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VIEvent -MaxSamples ([int]::MaxValue) -Start (Get-Date).AddDays(-7) |

  where {$_ -is [VMware.Vim.VmCreatedEvent]}


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

LucD,

Can we send this report for creation on a daily basis as a report to track over email instead of 7 days ? Please help.

Thanks

V

0 Kudos
LucD
Leadership
Leadership
Jump to solution

For mail you can use the Send-MailMessage cmdlet.

For scheduling on a daily basis you need to select a scheduler.

That can be the Windows Task Scheduler or a scheduler like cron on a Linux box.


I suggest you open a new thread when you have decided which scheduler you want to use.


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

0 Kudos
vmk2014
Expert
Expert
Jump to solution

Thak you, LucD. I'll do. Meanwhile, i am referring your old mail thread and you helped me earlier for vCheck. Trying to explore from vCheck plugin only, but problem is the Windows tasks scheduler never works with vCheck.

Thanks

V

0 Kudos