Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have few log files in different servers and I want to check output in the end of those log files for e.g . success: 4000 failed: 200 These logs files are getting generated daily and I have to keep track of these numbers. If there is any way I can automate this option instead of going and checking these files and wasting so much of my time.

I want to create some kind of script like Go to \serverA\C$\log_07_02_2012.txt and check this line Go to \serverB\C$\log_07_02_2012.txt and check some other line.


and it should give me output from all of these...

share|improve this question

Try this out. I'm sure it needs some modification to get exactly what you are looking for, but is a start.

$servers = Get-Content <path to txt file with list of server names>
ForEach ($server in $servers) {
    select-string \\$server\c$\PS\log_$(date -f MM)_$(date -f dd)_$(date -f yyyy).txt -pattern "<pattern in text file you are looking for>" | ForEach {$_.Line}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.