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

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

NameDescriptionRequired?Pipeline InputDefault Value
EntitySpecify objects (such as virtual machine, virtual machine host, resource pool, and so on) for which you want to collect events.falsetrue (ByValue)
StartSpecify 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
FinishSpecify 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
UsernameSpecify the user that has initiated the events you want to retrieve.falsefalse
MaxSamplesSpecify the maximum number of the events you want to collect.falsefalse
TypesSpecify the type of the events you want to collect. The valid values are Error, Info, and Warning.falsefalse
ServerSpecify 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

Input Type

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 --------------

C:\PS>Get-VIEvent -Entity (Get-VM -Name XP_VC_Tech) -Username admin -Type error 
-MaxSamples 15


Retrieves a list of the last fifteen error events on the XP_VC_Tech virtual mach
ine for the user admin.


destFolder           : VimApi.FolderEventArgument
destName             : WebTemplate
destHost             : VimApi.HostEventArgument
reason               : VimApi.LocalizedMethodFault
template             : False
key                  : 1482
chainId              : 1481
createdTime          : 07.5.2008 ?. 15:58:11
userName             : admin
datacenter           : VimApi.DatacenterEventArgument
computeResource      : VimApi.ComputeResourceEventArgument
host                 : VimApi.HostEventArgument
vm                   : VimApi.VmEventArgument
fullFormattedMessage : Failed to clone XP_VC_Tech: The attempted operation cann
                       ot be performed in the current state (Powered On).
dynamicType          :
dynamicProperty      :

destFolder           : VimApi.FolderEventArgument
destName             : WebTemplate
destHost             : VimApi.HostEventArgument
reason               : VimApi.LocalizedMethodFault
template             : False
key                  : 1480
chainId              : 1479
createdTime          : 07.5.2008 ?. 15:57:17
userName             : admin
datacenter           : VimApi.DatacenterEventArgument
computeResource      : VimApi.ComputeResourceEventArgument
host                 : VimApi.HostEventArgument
vm                   : VimApi.VmEventArgument
fullFormattedMessage : Failed to clone XP_VC_Tech: The attempted operation cann
                       ot be performed in the current state (Powered On).
dynamicType          :
dynamicProperty      :

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

C:\PS>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 " + $match
es[1] + " logged in at:" + $event.createdTime)} }


Gathers information for the users that have logged in.


User root logged in at:12/18/2008 12:26:02
User root logged in at:12/18/2008 12:26:02
User root logged in at:12/18/2008 12:00:51
User root logged in at:12/18/2008 12:00:50
User root logged in at:12/18/2008 12:00:47
User vpxuser logged in at:12/18/2008 12:00:46
User vpxuser logged in at:12/18/2008 12:00:46

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