< Back

Get-VIEvent

Sun Jan 19, 2020 6:53 pm

NAME Get-VIEvent



SYNOPSIS

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





SYNTAX

Get-VIEvent [[-Entity] <VIObject[]>] [-Finish <DateTime>] [-MaxSamples <Int32>] [-Server <VIServer[]>] [-Start

<DateTime>] [-Types <EventCategory[]>] [-Username <String>] [<CommonParameters>]





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

-Entity <VIObject[]>

Specifies objects (such as virtual machine, virtual machine host, resource pool, and so on) for which you want

to collect events.



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Finish <DateTime>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-MaxSamples <Int32>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Server <VIServer[]>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-Start <DateTime>

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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Types <EventCategory[]>

Specifies the type of the events you want to collect. The valid values are Error, Info, and Warning.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Username <String>

Specifies the user that has initiated the events you want to retrieve.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS

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.



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

Online Version: https://code.vmware.com/doc/preview?id= ... Event.html