Managing Your vCenter Events with PowerShell

While great, managing events with the the VI Client can be a pain. No search functionality, old events fall off the list, etc, etc. So what is an admin to do?

A resourceful admin will have been playing with the VI Toolkit, and would have found the get-vievent cmdlet. Let’s take a look at how we can manage VI Events using this cmdlet in a few different scenarios:

First lets see what this cmdlet can do for us:

image

Cool! So here I point out a limitation of the cmdlet (or VI, or both) It will only return 1000 events, that’s it:

PS C:\> get-vievent -MaxSamples 1000 | Measure-Object

Count    : 1000
PS C:\> get-vievent -MaxSamples 1350 | Measure-Object

Count    : 1000
That doesn’t make sense does it? Not sure if it’s a bug or not, but with some of the other filters, you can really dig into your events without having to get more than the first thousand.

Lets take a look at how to get a list of the first 3 errors for my VI specifically:

get-vievent -MaxSamples 3 -types error

2009-01-18_1618

Cool? Lets take a look at what this looks like… if I wanted the first 3 events on a particular host:

PS C:\> get-vievent -MaxSamples 3 -Entity (get-vmhost|select -First 1)

2009-01-18_1621

Let’s combine that, and the start & finish switches, to get 3 error events from our ESX server, from last Tuesday to last Thursday:

PS C:\> get-vievent -MaxSamples 3 -Start 01/13/2009 -Finish 01/15/2009 -Entity (get-vmhost | select -First 1)

2009-01-18_1624

So, even with the 1000 event limitation, it’s still a pretty powerful cmdlet, no?

Questions? Leave them in the comments.

4 thoughts on “Managing Your vCenter Events with PowerShell

Comments are closed.