【发布时间】:2017-01-29 18:38:17
【问题描述】:
此代码是每天通过电子邮件向我发送事件日志的错误,但我如何将应用程序和系统日志放在一封电子邮件中?谢谢。
$emailFrom = "admin@company.com"
$emailTo = "user@company.com"
$subject = "Daily Eventlog Errors"
$emailbody = get-eventlog -logname application -entrytype Error, Warning -after (get-date).addHours(-24) -computer (get-content c:\ServerList.txt) |
select MachineName, timewritten, source, message |format-table -auto | out-string
$message = New-Object Net.Mail.MailMessage($emailFrom, $emailTo, $subject, $emailbody)
$smtpServer = "companyemail.exchangemail.com"
$smtp = New-Object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($message)
【问题讨论】: