Sometimes I need a quick list of all my servers. This batch file does that for me
REM ====computerlist.cmd begins =====
@echo off
cls
cd /d %TEMP%
IF EXIST serverlist.txt DEL serverlist.txt
REM all on one line until FOR command
dsquery * domainroot -filter “(&(objectCategory=Computer)(objectClass=Computer)(operatingSystem=*Server*))” -limit 0 -attr cn >> serverlist.txt
FOR /F “skip=1” %%s in (serverlist.txt) do echo %%s >> “%USERPROFILE%\DESKTOP\serverlist.txt
if exist %TEMP%\serverlist.txt del %TEMP%\serverlist.txt
REM ====computerlist.cmd ends =====
Some notes. Domainroot will do the root of the current domain. The FOR command finishes with echo %%s >> “%USERPROFILE%\DESKTOP\serverlist.txt, which will create a new text file on your desktop. You can also use %%s a a parameter to any command, such as ping %%s.