$pattern = 'Unable to authenticate user!'
$events = Get-WinEvent -ea SilentlyContinue `
-ProviderName "Windows DB Controller - Task Manager Service"|
Where-Object { $_.TimeCreated -gt [datetime]::today -and $_.Message -match $pattern }
$events >> D:\Error.txt
if ($events) {
Send-MailMessage -SmtpServer smtp.domain.com -From [email protected] -To [email protected] -Subject 'Error found in log' -Body $events
}
我已經安排它每10分鐘跑和故意的,我想用上面的腳本來實現以下點:
Search the specified error message in the event viewer log only for current-date and as soon as the error message encountered send a email notification to me but didn't want to receive email notification for the error message which appreared today and for which I had already been notified (I mean , wanted to receive error-notification only once for a specific time of current day).
但我在這裏面臨的問題是:獲取多個通知相同的錯誤消息已被通知。
我希望我清楚地知道我確切的問題。
請問你能幫我解決這個問題嗎?
@HAL .. + 1。這似乎工作。我會在我的系統上測試它,並會讓你知道結果。 – Sunny