Some Active Directory date/times are stored as a long integer known as FILETIME, a count of 100 nanosecond intervals since January 01, 1601.
I have scripted FILETIME.BAT to return a date and time from a FILETIME.
The syntax for using FILETIME.BAT is:
call FILETIME FT DT TM
where:
FT is the long integer FILETIME, like the contents of LastLogon, LastLogonTimeStamp, and pwdLastSet. DT is a call directed environment variable that will contain the date in MM/DD/YYYY format. TM is a call directed environment variable that will contain the time in HH:MM:SS format.FILETIME.BAT contains:
@echo off if \{%3\}==\{\} @echo FileTime FT DT TM&goto :EOF if exist "%TEMP%\FileTime.vbs" goto doft @echo Dim WshShell, oExec, objArgs, exe, work >"%TEMP%\FileTime.vbs" @echo Set WshShell = CreateObject("WScript.Shell")>>"%TEMP%\FileTime.vbs" @echo Set objArgs = Wscript.Arguments>>"%TEMP%\FileTime.vbs" @echo exe = "w32tm.exe /ntte " ^& objArgs(0)>>"%TEMP%\FileTime.vbs" @echo set oExec = WshShell.Exec(exe^) >>"%TEMP%\FileTime.vbs" @echo Do While oExec.Status = 0 >>"%TEMP%\FileTime.vbs" @echo. WScript.Sleep 100>>"%TEMP%\FileTime.vbs" @echo Loop>>"%TEMP%\FileTime.vbs" @echo work = Split(oExec.StdOut.Read(60))>>"%TEMP%\FileTime.vbs" @echo Wscript.Echo work(3) ^& " " ^& work(4)>>"%TEMP%\FileTime.vbs" :doft If "%1" EQU "0" set %2=Never&set %3=Never&goto :EOF for /f "Tokens=1*" %%a in ('cscript //nologo "%TEMP%\FileTime.vbs" %1') do ( set %2=%%a set %3=%%b )
0 comments
Hide comments