I have scripted AllComputers.bat to generate CSV list of all the computers in a domain, showing the O/S, version, service pack, product name, and roles. The roles include:
Domain Controller (Y/N)
Global Catalog (Y/N)
"Schema","Domain naming","PDC","RID", and "Infrastructure" FSMO masters,
like the following sample:
"JSI001","5.2","Service Pack 1 v.1159","Microsoft Windows Server 2003","Y","Y","Schema","Domain","PDC","RID","Infrastructure" "JSI009","5.1","Service Pack 2 v.2082","Microsoft Windows XP","N","N","","","","","" "JSI005","5.0","Service Pack 4","Microsoft Windows 2000","N","N","","","","","" "JSI003","5.1","Service Pack 1","Microsoft Windows XP","N","N","","","","","" "JSI007","5.2","None","Microsoft Windows Server 2003","N","N","","","","",""The syntax for using AllComputers.bat is:
AllComputers.
The CSV list is displayed on the console, put you can pipe it to a file using:
AllComputers>FileName.
NOTE: AllComputers.bat uses AllFSMO.bat and IsGC.bat.
NOTE: If NETDOM.EXE is not installed on the computer you will use to run AllComputers.bat, install it from the Support / Tools folder of your O/S CD-ROM.
AllComputers.bat contains:
@echo off setlocal ENABLEDELAYEDEXPANSION set netdm=netdom query /domain:%userdnsdomain% set dc=Y for /f "Skip=1 Tokens=*" %%c in ('%netdm% dc^|find /v /i "The command completed successfully."') do ( set cmp=%%c call :doit ) set dc=N for /f "Skip=1 Tokens=*" %%c in ('%netdm% server^|find /v /i "The command completed successfully."') do ( set cmp=%%c call :doit ) for /f "Skip=1 Tokens=*" %%c in ('%netdm% workstation^|find /v /i "The command completed successfully."') do ( set cmp=%%c call :doit ) endlocal exit /b 0 :doit set work=%cmp: ( Workstation or Server )=% if "%work%" NEQ "%cmp%" set cmp=%work%# set cmp=%cmp: #=% set cmp=%cmp:#=% set cv= set sp= set pn= set gc=N for /f "Tokens=2*" %%r in ('reg query "\\%cmp%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion^|find "REG_SZ"') do set cv=%%s for /f "Tokens=2*" %%r in ('reg query "\\%cmp%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName^|find "REG_SZ"') do set pn=%%s set pn=!pn:,= ! call :csdv>nul 2>&1 if "%dc%" EQU "Y" call isgc "%cmp%" gc if "%dc%" EQU "Y" for /f "Tokens=1-6" %%r in ('AllFSMO') do ( set role1=%%s set role2=%%t set role3=%%u set role4=%%v set role5=%%w ) @echo "%cmp%","!cv!","!sp!","!pn!","!dc!","!gc!","!role1!","!role2!","!role3!","!role4!","!role5!" if "%dc%" EQU "Y" set role1=&set role2=&set role3=&set role4=&set role5= goto :EOF :csdv set sp=None for /f "Tokens=2*" %%r in ('reg query "\\%cmp%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v CSDVersion^|find "REG_SZ"') do set sp=%%s set sp=!sp:,= !NOTE: See tip 7717 » More on DSQUERY attribute filtering.
0 comments
Hide comments