Here is a working code based on @MagTuns answer regarding separate files for each logname
Added
Code
$Begin = '18/02/2025 00:00:00'
$End = '18/02/2025 00:59:59'
$path = "C:\temp\logevent\"
If(!(test-path $path))
{
New-Item -ItemType Directory -Force -Path $path
}
$allLog = (Get-WinEvent -ListLog * -ErrorAction SilentlyContinue).LogName
foreach ($lognameName in $allLog){
Write-Host "Processing $lognameName..."
$lognameFile = $lognameName.Replace("/", "-")
$datetimenow = [DateTime]::Now.ToString("yyyy_MM_dd HH_mm_ss")
Get-WinEvent -FilterHashtable @{logname = $lognameName; StartTime = "$Begin"; EndTime = "$End";Level=1,2,3; } -ErrorAction SilentlyContinue | Select-Object * | Out-File -Enc UTF8 -FilePath "$path$datetimenow_winevent_$lognameFile.txt"
}