I would like to read the contents of the Event Log on Windows using the Perl script. I can read the contents of the 'Application' Log. I can't read old logs - .evtx files. Can you advise me where I have a mistake?
$filename = "C:/Windows/System32/winevt/Logs/Archive-Application-2022-10-26-16-18-53-831.evtx";
if (-f $filename) {
printf "%s ... continue ...\n", $filename;
} else {
printf "PROBLEM\n";
exit -1;
}
$EventLog = new Win32::EventLog($filename) || die $!;
$EventLog->GetOldest($first) || die $!; # it dies here
EDIT:
Function GetOldest
returns a RecordNumber
. I tried UNC:
$filename = "\\\\<server>\\C\$\\Windows\\System32\\winevt\\Logs\\Archive-Application-2022-10-25-04-01-56-731.evtx";
... but the same error. The file exists but died on the GetOldest function. I haven't found something like $EventLog->errstr
anywhere on the internet ...
https://metacpan.org/pod/Win32::EventLog