if ($Hash) {
$body = "<table border='1'><tr><th>record<br>number</th><th>time</th><th>eventcode</th><th>sourcename</th><th>message</th>"
foreach ($item in $Hash) {
$body += "<tr><td>" + $item.recordnumber + "</td><td>" + $item.time + "</td><td>" + $item.eventcode + "</td><td>" + $item.sourcename + "</td><td>" + $item.message + "</td></tr>"
}
$body += "</tr></table>"
$params = @{
Body = $body
BodyAsHtml = $true
Subject = "ERROR for $DC"
From = 'admin@contonso.com'
To = 'user1@domain.ru', 'user2@domain.ru'
SmtpServer = '
exchange_server.contonso.com'
Port = 587
Priority = 'High'
Encoding = [System.Text.Encoding]::UTF8
}
Send-MailMessage
@params }