The following example gets the event log events that match the criteria.


Code Sample

# Gets the events that match the specified criteria.

$criteria = $administration.GET_DefaultEventLogCriteria();


# Optionally configure the required criteria.

$criteria.Username = "*Administrator*";

$criteria.MaximumResultCount = 100


 

# Get the event log entries, and optional attributes.

$entries = $administration.GET_EventLogEntries($criteria);

foreach ($entry in $entries.Event)

{

    Write-Host "------------- Entry -------------";

    Write-Host $entry.CreationDate;

    Write-Host $entry.EntryCodeString;

    Write-Host $entry.Message;

    Write-Host $entry.EntryCode;

    foreach ($attribute in $entry.Attributes.Attribute)

    {

        Write-Host "$($attribute.InformationTypeDisplayName): $($attribute.Value)";

    }