Skript, mis leiab application log'ist viimase nädala joosul tehtud "Error" tüüpi kirjed ja edastab need administraatorile e-kirjana Powershell: Difference between revisions

From ICO wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Category: Skriptimiskeeled]]
<source lang="powershell">
<source lang="powershell">
$emailFrom = "user@yourdomain.com"
Get-EventLog -logname application -EntryType error -newest 25| convertto-html > applogs.html
$emailTo = "kaspar.prei@gmail.com"
$filename = “applogs.html”
$subject = "error logid"
$smtpServer = “mail.uninet.ee”
$body = Get-EventLog -logname application -EntryType error -newest 25
 
$smtpServer = "mail.starman.ee"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($filename)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Send($emailFrom, $emailTo, $subject, $body)
 
$msg.From = “application@logid.com”
$msg.To.Add(”email.email@gmail.com”)
$msg.Subject = “Application errorlogs”
$msg.Body = “Viimased 25 Application error logi”
$msg.Attachments.Add($att)
 
$smtp.Send($msg)

Latest revision as of 10:43, 13 May 2011


<source lang="powershell"> Get-EventLog -logname application -EntryType error -newest 25| convertto-html > applogs.html $filename = “applogs.html” $smtpServer = “mail.uninet.ee”

$msg = new-object Net.Mail.MailMessage $att = new-object Net.Mail.Attachment($filename) $smtp = new-object Net.Mail.SmtpClient($smtpServer)

$msg.From = “application@logid.com” $msg.To.Add(”email.email@gmail.com”) $msg.Subject = “Application errorlogs” $msg.Body = “Viimased 25 Application error logi” $msg.Attachments.Add($att)

$smtp.Send($msg)