troubleshooting Question

get errors on log

Avatar of bibi92
bibi92Flag for France asked on
13 Comments1 Solution16 ViewsLast Modified:
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

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros