Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

PowerShell script to list the file with specific pattern in the directories including its line number.

Hi,

I need some help with the PowerShell script modification below so that it can also show, which line number the search pattern showed up?

$FileType = '*.log'
$SearchPath = '\\PRODFS01-VM\Logs'
$SearchPattern = 'Error'
Get-ChildItem -Include $FileType -Recurse -Path $SearchPath | Select-String -Pattern $SearchPattern | Sort-Object -Unique -Property Path | Select-Object Path

Open in new window


I'm not the expert in RegEx, hence I am using the basic.

Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of footech
footech
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Albert Widjaja

ASKER

Thanks all !