Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created February 8, 2010 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaliy/298446 to your computer and use it in GitHub Desktop.
Save chaliy/298446 to your computer and use it in GitHub Desktop.
$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:"status-list@company.ua" -From:"status-list@company.ua" -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