Get vCenter Events using PowerCLI

Recently I needed to find if any virtual machines had been deployed or cloned on a particular day (in order to troubleshoot a storage issue).

The Tasks & Events view in the VI client only shows the last few days of events, so if you need to get events from an older date the only way is through PowerCLI.

Here is how to do get a list of events from vCenter Server using PowerCLI…

Script: Get vCenter events using PowerCLI

The script below is what I quickly wrote to find the information I was after (i.e. create and clone events) during a specific date range. You can change the script to gather other events or all events by tweaking the search criteria:

Script: Get list of unique vCenter events using PowerCLI

If you are looking for a list of all the different event types that you can filter on, then run the following PowerCLI script. It will output the name of all the unique events that occur between a date range. This will then assist you in knowing what to use as the event filter for the script above:

Let me know your thoughts in the comments below….



Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.