Forum Discussion
powershell script
Hi, Louaialobaidi
How about to using 'Task Scheduler" (taskschd.msc).
New scheduled task
- Trigger : Event ID 4740
- Action : Run powershell script (noti.ps1)
eg. noti.ps1 ########################################################################
$SMTPServer = '1.1.1.1' # Your SMTP Server
$Subject = 'Account Lock Notification'
$From = 'noti mail account'
$To = 'admin mail acount'
$Time = (get-date -Format yyyy.mm.dd)
$Body = "Some account locked out at $Time ."
# If you want to show locked accounts, it might be a good idea to proceed another way.
Send-MailMessage -From $From -To $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer ########################################################################
* Event ID 4740 (https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4740)
I did not provide a detailed script, but if you have any questions, please feel free to reply.