Я пытаюсь прочитать несколько текстовых файлов, в которых есть текст с датой и успехом.Идея состоит в том, чтобы читать журналы за последние 7 дней, которые постоянно успешны.
Пример журналов:
12/5/2018 3:40:08 AM: Something_secret.txt Successfully 6335
12/6/2018 3:40:06 AM: Something_secret.txt Successfully 6337
12/7/2018 3:40:10 AM: Something_secret.txt Successfully 6338
12/8/2018 3:40:09 AM: Something_secret.txt Successfully 6342
12/9/2018 3:40:09 AM: Something_secret.txt Successfully 6342
12/10/2018 3:40:11 AM: Something_secret.txt Successfully 6342
12/11/2018 3:40:07 AM: Something_secret.txt Successfully 6342
12/12/2018 3:40:10 AM: Something_secret.txt Successfully 6344
12/13/2018 3:40:10 AM: Something_secret.txt Successfully 6347
Тип журнала 2:
12/6/2018 3:40:06 AM: Something_secret.txt Successfully 6337
12/7/2018 3:40:10 AM: Something_secret.txt Successfully 6338
12/8/2018 3:40:09 AM: Something_secret.txt Successfully 6342
12/9/2018 3:40:09 AM: Something_secret.txt Successfully 6342
12/10/2018 3:40:11 AM: Something_secret.txt file Not found
12/11/2018 3:40:07 AM: Something_secret.txt Successfully 6342
12/12/2018 3:40:10 AM: Something_secret.txt Successfully 6344
12/13/2018 3:40:10 AM: Something_secret.txt file Not found
Я создал это
$files = gci C:\Users\Desktop\xx
foreach ($file in $files) {
$date = (Get-Date).AddDays(-7)-f 'MM/d/yyyy'
$today = ((Get-Date -Format MM/d/yyyy))
gc $file.FullName | where {
$_ -match $date -and
$_ -match $today -match 'Successfully'
} | select @{n='Pathoffile';e={$file.FullName}}
}