Made some changes to the script to add in a simple array (split) for checking other accounts that fall into this realm.
Doc - You out there?
Here is the modified code:
code:
BREAK ON
CLS
; -- Author - Kent Dyer
; -- Original Date - 30 May 2002
; -- Change Date - 4 June 2002
; -- Initially used Date Routine - http://kixtart.org/board/Forum2/HTML/000133.html
; -- Date Routine built/changes by BrianTX
; -- Optionally, you could use DateMath, SerialDate from
; -- http://scriptlogic.com/Kixtart/ViewFunction.asp?FN=SerialDate
; -- http://scriptlogic.com/Kixtart/ViewFunction.asp?FN=DateMath
; -- Added a simple array (using split) from Kix 4.x 6/4/02
; -- pieces taken from
; -- http://cwashington.netreach.net/depo/view.asp?Index=198&ScriptType=vbscript
; -- http://cwashington.netreach.net/depo/view.asp?Index=323&ScriptType=vbscript
; -- http://kixtart.org/board/ultimatebb.php?ubb=get_topic;f=2;t=003347
IF Left(@kix,1) < 4
?"This script requires Kixtart 4.x"
SLEEP 2
EXIT
ELSE
$ldomain = @domain
;$lstrusername = "servicesql" ; -- uncomment out if you don't want to use split
$lstrusername = Split("servicesql~~cbcwindu~~servicemmc", "~~") ; -- comment out if you don't want to use split
$mailhost = "smtphost.domain.com" ; -- fill in with your smtp server
$adminrecpt = "user@@domain.com" ; -- add in your e-mail address
FOR EACH $element IN $lstrusername ; -- comment out if you don't want to use split
;$userobj = GetObject("LDAP://PDC.DOMAIN.com,ou=Accounts,ou=Users,ou=Service Account Users,ou=SQL Service Accounts,cn=ServiceSql")
;$userobj = GetObject("WinNT://$LDomain/$lstrUserName") ; -- uncomment out if you don't want to use split
$userobj = GetObject("WinNT://$LDomain/$Element") ; -- comment out if you don't want to use split
$pwexpire = $userobj.passwordexpirationdate
?"UserName: " + $userobj.name
?"UserPasswordExpires: " + $pwexpire
$tt = SPLIT($pwexpire," ")
$mdy = SPLIT($tt[0],"/")
$expiredatearray = $mdy[2],$mdy[0],$mdy[1]
$currentdatearray = "@YEAR","@MONTHNO","@MDAYNO"
FUNCTION CalcDayofYear($ymdarray) ; Only works on non-millenium years after 2000.
$calendar = 31,28,31,30,31,30,31,31,30,31,30,31
IF VAL($ymdarray[0]) & 1 $ly = 0 ; leap year calculations
ELSE
IF (Val($ymdarray[0])/2) & 1 $ly = 0
ELSE
$ly = 1
ENDIF
ENDIF
$calendar[2] = $calendar[2] + $ly
$mdays = 0
FOR $m = 0 TO (Val($ymdarray[1]) -2)
$mdays = $mdays + $calendar[$m]
NEXT
$calcdayofyear = $mdays + $ymdarray[2]
ENDFUNCTION
$daystoexpire = CalcDayofYear($expiredatearray) - CalcDayofYear($currentdatearray)
?$daystoexpire
IF $daystoexpire <= 2
? "Password Change required within 2 days, please change"
;SHELL 'postie.exe -host:$MailHost -to:$AdminRecpt -from:"ServiceAccountChg" -s:"Password Change" -msg:"The service account: $lstrUserName needs to be changed."'
SHELL 'postie.exe -host:$MailHost -to:$AdminRecpt -from:"ServiceAccountChg" -s:"Password Change" -msg:"The service account: $Element needs to be changed."'
ELSE
? "Password will not expire for more than 2 Days, no action is needed"
ENDIF
NEXT ; -- comment out if you don't want to use split
ENDIF
Thanks!
- Kent