Files
powershell/Dennis_Scripts/LogSearcher.ps1
2023-03-09 09:06:25 +01:00

18 lines
657 B
PowerShell

& {
$path = 'd-drive\ifsbosystem\log\*.Log*' # Where and what to look for
$serverpattern = "REJK-P-APP" # server name pattern
$servercount = 1..4 # server 1..n
$searchpattern = '2016-02-01 09:42'
# ----------- code here ------------ #
$files = $servercount | ForEach-Object {
Get-Item ("\\$serverpattern{0:d3}\$path" -f $_) | Where Name -match '\.log'
}
$strings = $files | Select-String -Pattern $searchpattern
$openfiles = $strings | Out-GridView -PassThru
$openfiles | Sort-Object Path -Unique | ForEach-Object { & 'C:\Program Files (x86)\Notepad++\notepad++.exe' $_.Path }
}