Below I use this because a timeout throws and I simple want null to
return if a timeout occurs.

if (&{$ErrorActionPreference = 'SilentlyContinue'
$MEW.WaitForNextEvent()}) {

This worked on my desktop (XP) but on Server 2003 I get
"WaitForNextEvent" with "0" argument(s): "Timed out "

This is, what I hope is, all the relevant code from the main routine.

$MEW = new-object system.management.ManagementEven****cher(
"SELECT * FROM __InstanceCreationEvent
WHERE TargetInstance ISA 'Win32_NTLogEvent'
AND TargetInstance.LogFile = '$LogName'")
$MEW.Scope.Path = "\\$Machine\root\cimv2"
# Set timeout to 5 seconds so we can use [ctrl]C and/or expire
timers
$MEW.Options.Timeout = [timespan]'0:0:5'

.... irrelevant stuff....

# Wait for an event if at end-of-log and caller wants more
records. Loop
# with timeout so timers can be processed and [ctrl]c works.
while ($start -lt $Max -and
$start -ge ($Log.Entries.Count + $Log.entries[0].Index)) {
# Timeouts throw whereas I simply want $null returned
if (&{$ErrorActionPreference = 'SilentlyContinue'
$MEW.WaitForNextEvent()}) {
# Refresh the log object in case messages have rolled off the
bottom
$Log = new-object system.diagnostics.eventlog($LogName,
$Machine)}
elseif ($PTimer) {
# There have been no messages for 5 seconds, see if there are
timers to
# expire before waiting again.
$PTimer.ReportExpired($Log,$LastMsg)}
}