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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:
Dale Harris
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.
Dale Harris
http://msmvps.com/blogs/nuoyan/archive/2005/11/04/74367.aspx