Spent a few days going through a few dozen examples but, unfortunately, not found a solution yet. Hoping you guys can help.
I need to search a bunch of log files at once and on each line check today's date and for a specific string - and importantly, i need a count of the two combined occurrences. I can do the individual search using Select-String. Even together. however, getting a count of it - while searching for both items on the same line has been the biggest hurdle. Some of logs are renamed overnight and a suffix appended to them - this should explain the search criteria I've used.
This is the code example:
**$dateStr = Get-Date -Format "yyyy-mm-dd"
$searchStr = 'some.class.name'
(Get-ChildItem -Filter "*info*.log*" -Recurse | Select-String -pattern "$dateStr.$searchStr" -AllMatches).matches.count**
This version (i have many), is perhaps the simplest version and more instructive to what i am trying to achieve and for those who are willing to help.