Created
February 8, 2010 18:48
-
-
Save chaliy/298446 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$genDate = (Get-Date) | |
$startFrom = (Get-Date).AddMinutes(-30) | |
$events = Get-EventLog -LogName:Application -Source:"ASP.NET 2.0.50727.0" -After:$startFrom | |
if ($events){ | |
$body = New-Object System.Text.StringBuilder | |
if ($events.Count){ | |
$body.AppendFormat("Gents, please welcome {0} events.`n", $events.Count) | |
} else { | |
$body.Append("Gents, please welcome an event bellow.`n") | |
} | |
$body.AppendLine() | |
foreach ($event in $events) { | |
$body.AppendFormat("Issued: {0}`n", $event.TimeGenerated) | |
$body.AppendFormat("Node: {0}`n", $event.MachineName) | |
$body.AppendLine() | |
$body.AppendLine($event.Message) | |
$body.AppendLine("----------------------------------`n") | |
} | |
$body.AppendLine() | |
$body.AppendLine("Sincerely yours, Build Server") | |
$body.AppendFormat("Generated: {0}`n", $genDate) | |
$subj = [System.String]::Format("Status as of {0}", $genDate) | |
Send-MailMessage -To:"[email protected]" -From:"[email protected]" -Subject:$subj -Body:($body.ToString()) -SmtpServer:"mail.company.ua" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment