VBS judges local account password expiration email alerts

Source: Internet
Author: User

VBS judges local account password expiration email alerts

Recently, the company released a file server (FTP) is under attack, the above files are all modified not normal use, and then the most important thing is to put a note, that if you need to untie the use of the file, you need to pay an account for the decryption fee, But in the end we still did not follow the prompt to unlock the file of related operations, found some anti-virus software or not cracked, and finally gave up, through the backup of the data to restore, the event mainly indicates that we put in the daily public network server needs to change the password frequently, because the public network server does not add domain management, Therefore, only through the VBS script to obtain the local account and then obtain the information of the account, with the use of local policy password maximum 30 days to remind the Administrator to make periodic changes to improve the security of the server, the following is the script information for this operation for the required learning.

The local account information property sometimes sets the password never expires, so we will also be judged by the script. Use the system's scheduled tasks to define the execution scripts to achieve the final script execution results. specifically see below:

We end up with email reminders in the following format.

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m02/82/73/wkiom1dvjlmxfwypaacmbfzr3p8135.png "height=" 174 "/>

The code begins:

DIM&NBSP;GETDGETD&NBSP;=&NBSP;DATEDIFFNSENDMAIL&NBSP;GETIP,GETDFUNCTION&NBSP;DATEDIFFN () Dim wsdim  Rtdim rtarrdim lastsetdim enddateset ws = createobject ("Wscript.Shell") rt =  ws.exec ("Net user administrator"). Stdout.readallrtarr = split (RT,VBCRLF) for i=0 to ubound (Rtarr) If Mid (Rtarr (i), 1, 3) = "Last Set"  then ' If mid (Rtarr (i), 1,10) = "Password l"  thenlastset = mid (Rtarr (i), INSTR (Rtarr (i), "a"), Len (Rtarr (i)) ' Wscript.echo lastsetend ifif mid (Rtarr (i), 1, 3) = "Password to"   Then ' If mid (Rtarr (i), 1,10) = "Password e"  thenif instr (Rtarr (i), "a")  <> 0  thenenddate = mid (Rtarr (i), InStr (Rtarr (i), "J"), Len (Rtarr (i))) If datediff ("D", Lastset, EndDate)  <=66 then ' Datediffn = 5datediffn = datediff ("D", Lastset,enddate) Elseif datediff ("D", Lastset,enddate)  >=365 thendatediffn = " Never "End if ' wscript.echo enddateelsedatediffn = " never "end ifend ifnextend  functionfunction sendmail (Ip,dat) Dim ns,eodim passworddim stmpdim fromnamedim  TonameDim msg1Dim msg2Dim msgDim usersfromName =  "[email protected]"          ' sender toname =  ' [email protected] '                   ' Recipient stmp =  ' Smtp.ixmsoft.com "                  ' stmp  server address users =  "Gavin" password =  "Password2016"           ' sender password msg1 =  ' 

We judge by two criteria and send a prompt message to the specified message if the user's password expires in a few days.

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/82/73/wKioL1dVjcCgAeCrAADCLtRR9xQ095.png "height=" 260 "/>

If the user attribute is turned on and the password never expires, there will be an email alert.

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/82/73/wKioL1dVjcLhJyGXAAC5iU7LVHw025.png "height=" 229 "/>

We execute the script by scheduling the task

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/82/73/wKioL1dVjcOTbcG4AAGJjV_qtJI170.png "height=" 414 "/>

This article from "Gao Wenrong" blog, declined reprint!

VBS judges local account password expiration email alerts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.