Get-VIEvent Command | Vmware PowerCLI Reference

Get-VIEvent

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.

Syntax

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

Parameters

Required Parameter Name Type Position Features Description
optional Entity VIObject[] named
  • pipeline
  • wildcards
Specifies objects (such as virtual machine, virtual machine host, resource pool, and so on) for which you want to collect events.
optional Finish DateTime named
Specifies 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.
optional MaxSamples Int32 named
Specifies 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.
optional ProgressAction ActionPreference named
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null 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.
optional Start DateTime named
Specifies 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.
optional Types EventCategory[] named
Specifies the type of the events you want to collect. The valid values are Error, Info, and Warning.
optional Username String named
Specifies the user that has initiated the events you want to retrieve.

Output

System.Object

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.

Related Commands

VIEvent

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