powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Get-VIEvent



NAME
Get-VIEvent

SYNOPSIS
Retrieves information about the events on a vSphere server.

SYNTAX
Get-VIEvent [[-Entity] ] [-Start ] [-Finish ] [-Username ] [-MaxSamples t32>] [-Types ] [-Server ] []


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. Filte
rs 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
-Entity
Specify 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
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-Start
Specify the start date of the events you want to retrieve. The valid formats are dd/mm/yyyy and mm/dd/yyyy, dep
ending on the local machine regional settings.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Finish
Specify the end date of the events you want to retrieve. The valid formats are dd/mm/yyyy and mm/dd/yyyy, depen
ding on the local machine regional settings.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Username
Specify the user that has initiated the events you want to retrieve.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-MaxSamples
Specify the maximum number of the samples you want to retrieve. The default value is 100

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

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

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VimApi.Event


NOTES


Calling Get-VIEvent without any parameters might result in significant delays 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 c
hild resource pools, it will be returned twice. This issue will be fixed in the vSphere PowerCLI further releas
es.

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

C:\PS>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 --------------

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 " + $matches[1] + " logged in at:" + $event.createdTime)} }


Gathers information for the users that have logged in.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Get-VIEvent.html