User account locked out mail notification with HTML report

This script will send you an notification when an user account is locked out.

I modified the output, normally it would look like this:

____________________________________________________________________________

Subject:
    Security ID:        S-1-5-18
    Account Name:        DC
    Account Domain:        DOMAIN
    Logon ID:        0x3e7

Account That Was Locked Out:
    Security ID:        S-1-5-21-162996128-1511881221-1856903913-1149
    Account Name:        test

Additional Information:
    Caller Computer Name:    \\VM

____________________________________________________________________________

Let this script run with task scheduler on EventID 4740, you can do that like this

 

Batch file:

powershell -command "& 'C:\Powershell\account_locked_out.ps1' "

 

Please fill your own SMTP and email info etc.

Any questions of suggestions are welcome!
Enjoy
Anonymous
Parents
  • The string starting:

    At C:\Powershell\account_locked_out.ps1:6 char:11

    +     $HTML= <<<< @"

    is missing the terminator: "@.

    At C:\Powershell\account_locked_out.ps1:48 char:33

    +     del c:\powershell\html.html  <<<<

       + CategoryInfo          : ParserError: (    <title>Acco...hell\html.html :

      String) [], ParseException

       + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

    i fix it by removing the "@"

Comment
  • The string starting:

    At C:\Powershell\account_locked_out.ps1:6 char:11

    +     $HTML= <<<< @"

    is missing the terminator: "@.

    At C:\Powershell\account_locked_out.ps1:48 char:33

    +     del c:\powershell\html.html  <<<<

       + CategoryInfo          : ParserError: (    <title>Acco...hell\html.html :

      String) [], ParseException

       + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

    i fix it by removing the "@"

Children
No Data