How would you find all users that have not logged on since
last month?



How would you find all users that have not logged on since last month?..

Answer / mohammed rafique

Using only native commands, JSILLD.bat produces a sorted/formated report of Users who have not logged on since YYYYMMDD.
The report is sorted by UserName and list the user's full name and last logon date.
The syntax for using JSILLD.bat is:
JSILLD \Folder\OutputFile.Ext YYYYMMDD [/N]
where:
YYYYMMDD will report all users who have not logged on since this date.
/N is an optional parameter that will bypass users who have never logged on.
JSILLD.bat contains:

@echo off
setlocal
if {%2}=={} goto syntax
if "%3"=="" goto begin
if /i "%3"=="/n" goto begin
:syntax
@echo Syntax: JSILLD File yyyymmdd [/N]
endlocal
goto :EOF
:begin
if /i "%2"=="/n" goto syntax
set dte=%2
set XX=%dte:~0,4%
if "%XX%" LSS "1993" goto syntax
set XX=%dte:~4,2%
if "%XX%" LSS "01" goto syntax
if "%XX%" GTR "12" goto syntax
set XX=%dte:~6,2%
if "%XX%" LSS "01" goto syntax
if "%XX%" GTR "31" goto syntax
set never=X
if /i "%3"=="/n" set never=/n
set file=%1
if exist %file% del /q %file%
for /f "Skip=4 Tokens=*" %%i in ('net user /domain^|findstr /v /c:"----"^|findstr /v /i /c:"The command completed"') do (
do call :parse "%%i"
)
endlocal
goto :EOF
:parse
set str=#%1#
set str=%str:#"=%
set str=%str:"#=%
set substr=%str:~0,25%#
set substr=%substr: =%
set substr=%substr: #=%
set substr=%substr:#=%
if "%substr%"=="" goto :EOF
for /f "Skip=1 Tokens=*" %%i in ('net user "%substr%" /domain') do call :parse1 "%%i"
set substr=%str:~25,25%#
set substr=%substr: =%
set substr=%substr: #=%
set substr=%substr:#=%
if "%substr%"=="" goto :EOF
for /f "Skip=1 Tokens=*" %%i in ('net user "%substr%" /domain') do call :parse1 "%%i"
set substr=%str:~50,25%#
set substr=%substr: =%
set substr=%substr: #=%
set substr=%substr:#=%
if "%substr%"=="" goto :EOF
for /f "Skip=1 Tokens=*" %%i in ('net user "%substr%" /domain') do call :parse1 "%%i"
goto :EOF
:parse1
set ustr=%1
if %ustr%=="The command completed successfully." goto :EOF
set ustr=%ustr:"=%
if /i "%ustr:~0,9%"=="Full Name" set fullname=%ustr:~29,99%
if /i not "%ustr:~0,10%"=="Last logon" goto :EOF
set txt=%ustr:~29,99%
for /f "Tokens=1,2,3 Delims=/ " %%i in ('@echo %txt%') do set MM=%%i&set DD=%%j&set YY=%%k
if /i "%MM%"=="Never" goto tstnvr
goto year
:tstnvr
if /i "%never%"=="/n" goto :EOF
goto report
:year
if "%YY%" GTR "1000" goto mmm
if "%YY%" GTR "92" goto Y19
set /a YY=100%YY%%%100
set YY=%YY% + 2000
goto mmm
:Y19
set YY=19%YY%
:mmm
set /a XX=100%MM%%%100
if %XX% LSS 10 set MM=0%XX%
set /a XX=100%DD%%%100
if %XX% LSS 10 set DD=0%XX%
set YMD=%YY%%MM%%DD%
if "%YMD%" GEQ "%dte%" goto :EOF
:report
set fullname=%fullname% #
set fullname=%fullname:~0,35%
set substr=%substr% #
set substr=%substr:~0,30%
@echo %substr% %fullname% %txt% >> %file%

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More Microsoft Certifications Interview Questions

friend i have some question plz help me out 1 how hash function works on router 2 what is diffrence between broad cast doman and collison doman 3 what is the difference between L3 Switch and Router, If they Perform the same function why we need both of them?

1 Answers   TCS,


What Is IDE?

4 Answers  


How can you forcibly remove AD from a server, and what do you do later? • Can I get user passwords from the AD database?

2 Answers  


What is Active Directory Domains & Trust?

1 Answers   HCL, Wipro,


How do you backup Active Directory?

1 Answers  






What is tombstone lifetime attribute?

1 Answers  


What is a Console port and why is it used for and usually console is present in which Hardware devices ?

1 Answers  


How can you determine what GPO was and was not applied for a user? Name a few ways to do that.

2 Answers  


what is thinclient? why we use? and how to install thinclient? basic requirement?

3 Answers  


what is the function of DHCP?

17 Answers   Wipro, YTI,


hi im raghu im 26 yrs old can i take exams on mcse for windows server 2003 now instead of windows server 2008

3 Answers  


How do you change the DS Restore admin password?

1 Answers   DELL,


Categories
  • Cisco Certifications Interview Questions Cisco Certifications (2321)
  • Microsoft Certifications Interview Questions Microsoft Certifications (171)
  • Sun Certifications Interview Questions Sun Certifications (45)
  • CISA Certification Interview Questions CISA Certification (744)
  • Oracle Certifications Interview Questions Oracle Certifications (64)
  • ISTQB Certification Interview Questions ISTQB Certification (109)
  • Certifications AllOther Interview Questions Certifications AllOther (295)