Brian,

Works great..
quote:

UserName: ServiceSql
UserPasswordExpires: 7/9/2002 6:18:13 AM
Number of Days till password expires: 35
Password will not expire for more than 2 Days, no action is needed
UserName: cbcwindu
UserPasswordExpires: 8/28/2002 10:29:29 AM
Number of Days till password expires: 85
Password will not expire for more than 2 Days, no action is needed
UserName: servicemmc
UserPasswordExpires: 7/17/2002 7:26:16 AM
Number of Days till password expires: 43
Password will not expire for more than 2 Days, no action is needed

Added in your fix..

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[1] = $calendar[1] + $ly
$mdays = 0
FOR $m = 0 TO (Val($ymdarray[1]) -2)
$mdays = $mdays + $calendar[$m]
NEXT
$calcdayofyear = $mdays + $ymdarray[2]
ENDFUNCTION

$diffyears = VAL($expiredatearray[0]) - VAL($currentdatearray[0])
IF $diffyears > 0
$yearstodays = 0
FOR $countyear = VAL($currentdatearray[0]) TO (VAL($expiredatearray[0])-1)
$acountyear = $countyear,"12","31"
$yearstodays = $yearstodays + CalcDayofYear($acountyear)
NEXT
ENDIF

$daystoexpire = CalcDayofYear($expiredatearray) - CalcDayofYear($currentdatearray) + $yearstodays
?"Number of Days till password expires: " + $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

Added in a small piece to tell you visually how many days it will be when the password expires..

Thanks!

- Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's