Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.