# Using [System.Diagnostics.EventLog] for Powershell 3.0 Beta
# Code
# Clearing variable types
rv -ea 0 i;
rv -ea 0 var
$var=@("a","b","c","d","e"); foreach ($i in $var) {rv -ea 0 $i}
#Creating $a specific to the 'GetEventLogs()'
# method for [System.Diagnostics.EventLog]
$a=[System.Diagnostics.EventLog]::GetEventLogs()
$a | gm -s
# List the event logs
$a
# Creating $a as generic to the .NET class; Querying active
# Eventlog for a local(or remote?)computer name:
$a=[System.Diagnostics.EventLog]
$a::GetEventLogs("rmfvpc")
$a::GetEventLogs("rmfvpc") | gm -s
# Creating $B as the result of mahine specific
#'GetEventLogs()' query
$b=$a::GetEventLogs("rmfvpc")
$b | gm -s
$b | gm -f
# Using $B to get a specific method for a specific log (e.g.
# Array[10]) for specific configuration method (e.g.
# 'get_OverflowAction()')
$b[10]
$b[10].get_OverflowAction()
# Choose the Security Log
$C = $B | Where Log -eq Security
# This retrieves all Entries before returning the first index.
$c[0].get_Entries()[0]
$c[0].get_Entries()[0] | gm -f
#Returns select entries and then select EventIDs for such.
$c[0].get_Entries()[100..110]
$c[0].get_Entries()[100..110]
$c[0].get_Entries()[100..110].get_EventID()
# Number of Events Logs; Number of total events for a
# specific Event Log.
$c[0].count
$c[0].Entries.count
# Returns First and Last Events
$lc = $($c[0].Entries.count - 1)
$c[0].get_Entries()[0,$($c[0].Entries.count - $lc)]
# Creates a DateTime variable;Returns number of days
# between first and last events
($c[0].get_Entries()[0,$lc]).TimeGenerated
$TG=($c[0].get_Entries()[0,$lc]).TimeGenerated
$TG | gm -s
$TG[1]-$TG[0]
($TG[1]-$TG[0]).Days
# Returns select sorted information last 1000 entries
$d=($c[0].get_Entries())[0..999]| Select EventID,Message
$d.count
$d[0..9] | ft -auto -wrap
$d | group -property EventID -noelement | sort -desc -property Count
$e= ($d | group -property Message -noelement | sort -desc -property Count)
$e.count
$e[0..9] | ft -auto -wrap