In tip 6790, we determined Who is currently logged on to your domain?.
Using NETDOM from the Server Support Tools and Psloggedon freeware, I have scripted WhoDomNot.bat to determine what domain computers do not currently have domain users logged on.
The syntax for using WhoDomNot.bat is:
WhoDomNot NetBIOSDomainName ReportFile User Password
where:
NetBiosDomainName is the NetBIOS domain name of the domain your are querying, like JSIINC.
ReportFile is the report file, like WhoDomNot.TXT or \\Server\ShareName\WhoDomNot.log.
User is the User ID that has permissions to run Netdom.exe on the NetBIOSDomainName domain, and has RWXD permissions on ReportFile.
Password is the password of User.
WhoDomNot.bat contains:
@echo off setlocal if \{%4\}==\{\} goto syntax set domain=%1 set report=%2 set user=%3 set password=%4 set domain=%domain:"=% set user=%user:"=% set password=%password:"=% set old=## if exist %report% del /q %report% for /f "skip=1 Tokens=1" %%u in ('netdom.exe query /domain:"%domain%" /UserD:"%user%" /PasswordD:"%password%" DC') do call :computer "%%u" for /f "skip=1 Tokens=1" %%u in ('netdom.exe query /domain:"%domain%" /UserD:"%user%" /PasswordD:"%password%" SERVER') do call :computer "%%u" for /f "skip=1 Tokens=1" %%u in ('netdom.exe query /domain:"%domain%" /UserD:"%user%" /PasswordD:"%password%" WORKSTATION') do call :computer "%%u" endlocal goto :EOF :syntax @echo Syntax: WhoDomNot NetBIOSDomainName ReportFile User Password endlocal goto :EOF :computer set OK=N set machine=%1 set machine=%machine:"=% if "%machine%" EQU "The" goto :EOF if "%machine%" EQU "Directory" goto :EOF for /f "Skip=1 Tokens=*" %%l in ('psloggedon "\\%machine%" -l^|Find /v " if "%OK%" EQU "Y" goto :EOF if "%old%" EQU "%machine%" goto :EOF @echo %machine%>>%report% set old=%machine% goto:EOF :who call set work=%%line:%domain%=%% if "%work%" EQU "%line%" goto :EOF set OK=Y