I have scripted LoSince.bat to report user accounts that haven't logged on since a date you specify.

LoSince.bat requires that you implement tip 10492 ยป How can I record logon and logoff information in both the user account description and the computer account description?, and that you download ADFind.exe freeware and place it in a folder that is in your PATH.

The syntax for using LoSince.bat is:


Where YYYYMMDD is the 4 digit year, 2 digit month, and 2 digit day that you specified.

LoSince.bat contains:

@echo off                              setlocal EnableDelayedExpansion                              if \{%1\}==\{\} goto err                              set since=%1                              set adfswitch=-csv -csvdelim ";" -nocsvheader -nodn -default -f "&(objectcategory=person)(objectclass=User)"                              set adfattr=Name distinguishedName description                              for /f "Tokens=1-2* Delims=;" %%a in ('adfind %adfswitch% %adfattr%') do (                               set Name=%%a                               set DN=%%b                               set desc=%%c                               call :test                              )                              endlocal                              goto :EOF                              :err                              @echo Syntax: LoSince YYYYMMDD                              goto :EOF                              :test                              if "!desc:~1,3!" NEQ "ON " goto report                              set wrk1=!desc:"=!                              set wrk2=%wrk1:OFF =%                              if "%wrk1%" EQU "%wrk2%" goto report                              if "!desc:~4,8!" GTR "%since%" goto :EOF                              :report                              @echo !Name!;!DN!