PowerCLI Reference

Get-VIEvent

Synopsis

This cmdlet retrieves information about the events on a vCenter Server system.

Syntax

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

Related Commands

Online version

Detailed Description

This cmdlet retrieves information about the events on a vCenter Server system. An event is any action in the vCenter Server system or ESX/ESXi host. You can filter retrieved events by specifying arguments for the cmdlet parameters. Filters are additive. For example, when you specify the Entity, Start, and Finish parameters, Get-VIEvent filters 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[]Specifies objects (such as virtual machine, virtual machine host, resource pool, and so on) for which you want to collect events.falsetrue (ByValue)
FinishDateTimeSpecifies 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
MaxSamplesInt32Specifies the maximum number of retrieved events. When you do not filter events by time period, the maximum number of retrieved events is set to 100 by default.

Note: This parameter is ignored when the Start and Finish parameters are specified and all events from the specified period are retrieved.
falsefalse
ServerVIServer[]Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
StartDateTimeSpecifies 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[]Specifies the type of the events you want to collect. The valid values are Error, Info, and Warning.falsefalse
UsernameStringSpecifies the user that has initiated the events you want to retrieve.falsefalse

Return Type

Zero or more VimApi.Event objects

Notes

Calling Get-VIEvent without any parameters might result in significant delays depending on the total number of events on the server. Get-VIEvent might return duplicates in the output. For example, if a virtual machine is the child of both a parent and a child resource pools, it will be returned twice. This issue will be fixed in future releases of VMware PowerCLI.

Examples

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

Get-VIEvent -Entity MyVM1 -Username admin -Types error -MaxSamples 15

Retrieves a list of the last fifteen error events on the MyVM1 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 © VMware, Inc. All rights reserved.