Search string with Get-Content and show x lines before/after result
Posted: 2022-Dec-26, 12:23 pm
I need to search a string in a file, and it show me the string and their x lineas before/after string, I tryed several sintaxis but I donĀ“t know how do it. Could someone help me?
Example:
Get-Content -Path C:\Mi-log.txt | where { $_ -match "text-I-want-to-search" } -tail 5
Example:
Get-Content -Path C:\Mi-log.txt | where { $_ -match "text-I-want-to-search" } -tail 5