I'm trying to get all the ERROR and WARN lines to files with the name of an object, like the following:
$items = Get-ChildItem -Path "C:\Test"
foreach ($item in $items)
{
gci $item *.log* -rec -Force -ErrorAction SilentlyContinue |
Select-String "WARN|ERROR" >> "C:\MyDir$item.Name_logTest.txt"
}
However, the recursive flag doesn't allow me to go over all folders.
EDIT: Guys, I figured it out. Instead of using "gci $item", I used "gci $item.PSPath"