Link to home
Start Free TrialLog in
Avatar of fireburn11
fireburn11

asked on

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
Thanks
Avatar of Joseph Daly
Joseph Daly
Flag of United States of America image

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.

http://msmvps.com/blogs/nuoyan/archive/2005/11/04/74367.aspx
ASKER CERTIFIED SOLUTION
Avatar of KenMcF
KenMcF
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ken,

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.

Fireburn11,

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
$SMTPClient.Send($From,$To,$Title,$body)
#This can be cleaned up to use "Send-MailMessage" CMDLet.

Open in new window


Dale Harris