既然你已经标记了powershell,你就可以做这样的事情。
Get-WinEvent -FilterHashtable @{Logname='Some log name'} |
Where-Object message -match 'with return code (?<ErrorCode>.+?)\.' |
Foreach-Object {
# Send mail code here
Send-MailMessage ...
# Some info that may be useful
$_.TaskDisplayName
$_.TimeCreated
$_.MachineName
$matches.ErrorCode
}