(view source code of listadcomputers.bat as plain text)
@ECHO OFF
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
ECHO.%* | FIND "/?" >NUL && GOTO Syntax
DSGET.EXE /? >NUL 2>&1 || GOTO Syntax
SETLOCAL ENABLEDELAYEDEXPANSION
SET Count=0
IF "%~1"=="" (
SET Name=*
SET Node=
) ELSE (
SET Name="%~1"
IF "%~2"=="" (
SET Node=
) ELSE (
SET Node="%~2"
)
)
FOR /F "tokens=2 delims==," %%A IN ('DSQUERY Computer %Node% -name %Name% -limit 10000 ^| SORT') DO (
SET /A Count += 1
ECHO.%%~A
)
> CON ECHO.
> CON ECHO [%Count% Computers]
ENDLOCAL
GOTO:EOF
:Syntax
ECHO ListADComputers.bat, Version 1.00
ECHO List computer objects in Active Directory
ECHO.
ECHO Usage: LISTADCOMPUTERS [ filter [ node ] ]
ECHO.
ECHO Where: filter limits the listed computer objects by (part of) their names
ECHO (wildcards * allowed)
ECHO node is an optional start node in the active directory tree, e.g.
ECHO "OU=Management,DC=robvanderwoude,DC=com" (quotes required)
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
IF "%OS%"=="Windows_NT" EXIT /B 1
page last modified: 2024-04-16; loaded in 0.0048 seconds