vSphere PowerCLI Reference

Get-VIEvent

Synopsis

Retrieves information about the events on a vSphere server.

Syntax

Get-VIEvent [[-Entity] <VIObject[]>] [-Start <DateTime>] [-Finish <DateTime>] [-Username <String>] [-MaxSamples <Int32>] [-Types <EventCategory[]>] [-Server <VIServer[]>] [<CommonParameters>]

Related Commands

Online version

Detailed Description

Retrieves information about the events on a vSphere server. An event is any action in the vCenter Server system or ESX host. The cmdlet collects events that correspond to the filter criteria defined by the cmdlet parameters. Filters are additive and the Entity. Start, and Finish parameters filter the events both by the entity and the timestamp properties. To specify a server different from the default one, use the -Server parameter.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
EntityVIObject[]Specify objects (such as virtual machine, virtual machine host, resource pool, and so on) for which you want to collect events.falsetrue (ByValue)
FinishDateTimeSpecify the end date of the events you want to retrieve. The valid formats are dd/mm/yyyy and mm/dd/yyyy, depending on the local machine regional settings.falsefalse
MaxSamplesInt32Specify the maximum number of the samples you want to retrieve. The default value is 100falsefalse
ServerVIServer[]Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
StartDateTimeSpecify the start date of the events you want to retrieve. The valid formats are dd/mm/yyyy and mm/dd/yyyy, depending on the local machine regional settings.falsefalse
TypesEventCategory[]Specify the type of the events you want to collect. The valid values are Error, Info, and Warning.falsefalse
UsernameStringSpecify the user that has initiated the events you want to retrieve.falsefalse

Return Type

VimApi.Event

Notes

Calling Get-VIEvent without any parameters might result in significant dela ys depending on the total number of events on the server. Get-VIEvent may return duplicates in the output. For example, if a virtual machine is a child of a parent and child resource pools, it will be returne d twice. This issue will be fixed in the vSphere PowerCLI further releases.

Examples

-------------- Example 1 --------------

Get-VIEvent -Entity VM -Username admin -Type error -MaxSamples 15

Retrieves a list of the last fifteen error events on the VM virtual machine for the user admin.

-------------- Example 2 --------------

Connect-VIServer -Server 10.23.113.41   $events = Get-VIEvent -MaxSamples 100  foreach ($event in $events) {if  ($event.fullFormattedMessage -match "User (.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b logged in") {Write-Host ("User " + $matches[1] + " logged in at:" + $event.createdTime)} }

Gathers information for the users that have logged in.


Copyright © 1998 - 2011 VMware, Inc. All rights reserved.