(view source code of dhcpscopes.bat as plain text)
@ECHO OFF
REM Obtains all active DHCP Scopes authorized in the domainREM Josh Murray V. 6.8.18SETLOCAL ENABLEDELAYEDEXPANSION
ECHO dhcp > script2.txt
ECHO set file open dhcp.txt >> script2.txt
REM Import DHCP ServersECHO dhcp > script1.txt
ECHO set file open temp.txt >> script1.txt
ECHO show server >> script1.txt
ECHO exit >> script1.txt
NETSH -f script1.txt >nul
REM Check if servers are reachableCLS
ECHO Scanning Servers
ECHO Server not responding (If name is Address, there is a blank entry in AD) :> error.log
FOR /F "tokens=2 delims=[]" %%A in (temp.txt) DO (
PING -n 2 %%A | FIND "TTL=" >NUL
IF !ERRORLEVEL! NEQ 0 (
ECHO Server unreachable %%A >> error.log
) ELSE (
ECHO server \\%%A >> script2.txt
ECHO show scope >> script2.txt
)) ECHO exit >> script2.txt
REM Get scopesCLS
ECHO Enumerating Scopes
NETSH -f script2.txt >NUL
REM Cleanup LogsTYPE dhcp.txt | FIND "Active" > Scopes.txt
ECHO ******************************>> error.log
ECHO DHCP Service may be disabled: >> error.log
TYPE dhcp.txt | FIND "Unable to determine" >> error.log
DEL temp.txt
DEL script*
CLS
ECHO Complete, Check Scopes.txt for DHCP scopes and error.log for failed connections.
ENDLOCAL
PAUSE
page last modified: 2025-10-11; loaded in 0.0051 seconds