Answers:
试一试。您可以定义日志的位置,错误代码的内容等。使其成为您自己的。如果你想使用gmail发送消息,我会看到一段时间的教程。我相信你能找到它。
Try
{
Database dump commands
}
Catch
{
Write-EVentLog -LogName Application -Source "Baller Script" -EntryType Error -EventID 42 -Message "There has been a failure..."
Send-MailMessage -From ExpensesBot@MyCompany.Com -To bro@baller.com -Subject "DBDump is broke as hell! (Event ID: 42)" -SmtpServer exch@baller.com
Break
}