JSI Tip 10610. How can I rapidly determine the availability of all the computers in the domain I am logged onto?

Using ADFind.exe freeware and CMPAvail.bat, I have scripted Available.bat to rapidly return the NetBIOS computer names of all the computers in the domain you are logged onto, and an available switch. If the switch is Y, the computer is available. If the switch is N, the computer is not available.

NOTE Available.bat bypasses disabled computer accounts.

NOTE: You must run Available.bat from Windows Server 2003 or Windows XP.

To use Available.bat in a script:

for /f "Tokens=1,2" %%a in ('Available') do (
:: Do something with %%a which is the NetBIOS computer name of each computer, %%b is the available switch, like:
 @echo %%a %%b
)
See How can I enable and start a service on all the computers in my domain?

Available.bat contains:

@echo off
setlocal
set qry=adfind -default -f "&(objectcategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=2)" -ps 99999 -nodn -noctl
set /a cnt=0
for /f "Tokens=1* Delims=:" %%c in ('%qry%^|Findstr /B /L /C:">name: "') do (
 call :PCOK %%d
)
if %cnt% EQU 0 goto finish
set /a delay=7
set /a delay=%delay% + (%cnt% / 100)
@ping -n %delay% 127.0.0.1>nul
for /f "Tokens=*" %%a in ('dir "%TEMP%\Available_*.log" /b') do (
 for /f "Tokens=1* Delims=," %%x in ('type "%TEMP%\%%a"') do (
    @echo %%x %%y
 )
 del /q "%TEMP%\%%a"
)
del /q "%TEMP%\Available_*.bat"
:finish
endlocal
goto :EOF
:PCOK
set /a cnt=%cnt% + 1
@echo call CMPAvail %1 OK>"%TEMP%\Available_%cnt%.bat"
@echo @echo %1,%%OK%%^>"%TEMP%\Available_%cnt%.log">>"%TEMP%\Available_%cnt%.bat"
@echo exit>>"%TEMP%\Available_%cnt%.bat"
start /min /high CMD /c "%TEMP%\Available_%cnt%.bat"



TAGS: Windows 8
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