Using ADFind.exe freeware, I have scripted ADComp.bat to return the NetBIOS and distinguished name of all the computers in the domain you are logged on to.
The syntax for using ADComp.bat is:
for /f "Tokens=1* Delims=;" %%c in ('call ADComp') do ( set name=%%c set dn=%%d . . . )NOTE: The output of ADComp.bat is a semi-colon delimited string, like:
JSI001;"CN=JSI001,OU=Domain Controllers,DC=JSIINC,DC=COM" JSI009;"CN=JSI009,CN=Computers,DC=JSIINC,DC=COM"ADComp.bat contains:
@echo off setlocal ENABLEDELAYEDEXPANSION set qry=adfind -default -f "&(objectcategory=computer)" -ps 99999 -nodn -noctl for /f "Tokens=*" %%c in ('%qry%^|Find /I "name: "') do ( set work=%%c if "!work:~1,19!" EQU "distinguishedName: " set dn="!work:~20!" if "!work:~1,6!" EQU "name: " @echo !work:~7!;!dn! ) endlocal
0 comments
Hide comments