Powershell script to read in a text file that contains computer names then print out computer names that has event ID 113

Hi All,

I have  a text file that contains all server names. Each line in the text file is the server name.

I need a PS script to read in the file, look for even ID 113 on that computer than print out the name of the server to a text file if found.

Please help! We are at 2008 R2
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joseph DalyCommented:
I dont know if a powershell script is mandatory on this one but if not you may want to take a look at microsofts tool eventcombmt. This tool lets you add computers from a text files and then search them for specific error messages and returns a log for each one found.

You could use something like this. You will need to change the log if it is not the application log you want to search.

$comps = gc c:\computers.txt
$out = @()
foreach($comp in $comps){
$evt = get-eventlog -computername $comp -log application | where {$_.eventID -eq 113}
if ($evt -ne $null){
$out += $comp
$out | out-file c:\event113.txt

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dale HarrisProfessional Services EngineerCommented:

Great script.

I don't want to take away from your answer, but also offer a script that I created to find all errors within the last 24 hours on critical servers and email the list.


This may help you.  I'm not wanting credit for the answer, just wanted to pass on some useful scripts we created:

#Script to grab errors in the application event log from critical servers
$Date = get-date
$Count = [int]0
"" > EventLogRollup.txt
$ShortDate = $Date.ToShortDateString()
$ServerList = gc "complist.txt"
foreach ($Server in $ServerList){
$EventLog = ""
$EventLog = get-eventlog -computername $Server "Application" -entrytype "error" -after ((get-date).adddays(-1))
$Count += $EventLog.count
"$Server`n" >> "EventLogRollup.txt"
$Eventlog | Group-Object -property EventID -noelement | sort-object -property count -descending >> "EventLogRollup.txt"
"`n" >> "EventLogRollup.txt"
}#end server list

$arrSummary = get-content "EventLogRollup.txt"
foreach($Line in $ArrSummary){
$Rollup += "$Line`n"

$SMTPServer = "EXCHSERVER.DOMAIN.COM";$From = "Test@PS.com";$To = "MailAddress@domain.com";$SMTPClient = New-Object system.Net.Mail.SmtpClient;$SMTPClient.host = $SMTPServer
$Title = "$Count Errors on Critical Servers"
$Body = "$Rollup"

$SMTPClient = New-Object system.Net.Mail.SmtpClient
$SMTPClient.host = $SMTPServer
#This can be cleaned up to use "Send-MailMessage" CMDLet.

Open in new window

Dale Harris
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Printers and Scanners

From novice to tech pro — start learning today.