AutoIt
$Output="" $strComputer = "localhost" $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") If @Error Then $Output = $Output & "Computer: " & $strComputer & ":" & @CRLF & " UNREACHABLE" & @CRLF & @CRLF Else $Output = $Output & "Computer: " & $strComputer & @CRLF $Output = $Output & "==========================================" & @CRLF $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkLoginProfile", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) then For $objItem In $colItems $Output = $Output & "Caption: " & $objItem.Caption & @CRLF $Output = $Output & "Comment: " & $objItem.Comment & @CRLF $Output = $Output & "LastLogon: " & WMIDateStringToDate($objItem.LastLogon) & @CRLF $Output = $Output & "Name: " & $objItem.Name & @CRLF $Output = $Output & "NumberOfLogons: " & $objItem.NumberOfLogons & @CRLF $Output = $Output & "PasswordAge: " & round($objItem.PasswordAge / 86400) & " days" & @CRLF $Output = $Output & "PasswordExpires: " & WMIDateStringToDate($objItem.PasswordExpires) & @CRLF & @CRLF Next Endif EndIf msgbox(0, '' , $Output) Func WMIDateStringToDate($dtmDate) Return (StringMid($dtmDate, 5, 2) & "/" & _ StringMid($dtmDate, 7, 2) & "/" & StringLeft($dtmDate, 4) _ & " " & StringMid($dtmDate, 9, 2) & ":" & StringMid($dtmDate, 11, 2) & ":" & StringMid($dtmDate,13, 2)) EndFunc
Does password age look right to anyone, its off by many hundreds of days on some, closer on others, but rarely accurate? Any idea how to make this return reliable, or where to go get the actual password age.