Avatar of bibi92
bibi92
Flag for France

asked on 

get errors on log

Hello,
dly_test.log contains :
21/05/2021 00:56:56 ERR1014 Une erreur s'est produite.
01/06/2021 00:22:10 ERR1016 Une interruption s'est produite.
04/06/2021 11:40:15 ERR1012 Le planificateur a été stoppé


I want to get errors during $LDays = 3  :

$Time  = (Get-Date).AddDays(-$LDays).ToString('dd/MM/yyyy hh:mm:ss')

LogPath = "C:\TEMP\Log"  
$Log = Get-ChildItem -path $LogPath -recurse -include dly_test.log
$ListError = 'ERR1014','ERR1016','ERR1012','ERR1011','ERR1013'

$Error = Get-Content -Path $Log|
Where-Object { $_ -contains $ListError -and ($_ -split ' ')[0] -gt $Time }

Thank you

Regards
Powershell

Avatar of undefined
Last Comment
bibi92

8/22/2022 - Mon