My goal is to get the amount of EventLog Entries of a specific Log with a small powershell script. The amount should be converted to a variable.
Now I am at a point that I really dont know how to accomplish this. Can you help? Maybe there is an Option in Get-WinEvent?
Thanks in advance for any help.
CodePudding user response:
Sure, the -ListLog
parameter will help you get a count.
Here are some examples
A specific log (eg: Application)
$ApplicationLogsCount = (Get-WinEvent -ListLog Application).RecordCount
All logs
$AllLogs = Get-WinEvent -ListLog * | Select LogName,RecordCount
All non-empty logs
$AllNonEmptyLogs = Get-WinEvent -ListLog * | Select LogName,RecordCount | Where-Object -Property RecordCount -gt 0
References