Skip navigation

JSI Tip 10495. Which domain member computers do not have a user currently logged on?

I have scripted NoLogon.bat to report domain member computers that do not currently have a user logged onto the console.

NoLogon.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 NoLogon.bat is:

NoLogon

NoLogon.bat contains:

@echo off
setlocal EnableDelayedExpansion
set adfswitch=-csv -csvdelim ";" -nocsvheader -nodn -default -f "&(objectcategory=Computer)"
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
:test
if "!desc:~1,3!" NEQ "ON " goto report
set wrk1=!desc:"=!
set wrk2=%wrk1:OFF =%
if "%wrk1%" EQU "%wrk2%" goto report
set wrk2=%wrk1:OFF 0=%
if "%wrk1%" EQU "%wrk2%" goto report
goto :EOF
:report
@echo !Name!;!DN!



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish