JSI Tip 10049. How can you report any DNS zone that does NOT have scavenging turned on after you 'Set Aging/Scavenging for All Zones'?

Using REG.EXE, built into Windows XP, Windows Server 2003, and later operating systems, or installed from the Windows 2000 Support Tools, I have scripted Scavenging.bat to display the DNS zone names that are NOT being scavenged after you Set Aging/Scavenging for All Zones.

The syntax for using Scavenging.bat, on any domain computer, is:

@echo off
for /f "Tokens=1,2* Delims=," %%x in ('Scavenging \[LAN\]') do (
 if %%x EQU "Y" If %%y EQU "N" @echo %%z
Where LAN is optional name of your connection, like JSIINC. If not specified, it will default to Local Area Connection.

Scavenging.bat contains:

@echo off
set LAN="Local Area Connection"
if \{%1\} NEQ \{\} set LAN=%1
set LAN=%LAN:"=%
set LAN=Ethernet adapter %LAN%:
set OK=N
set Zone=NONE
for /f "Tokens=*" %%a in ('IPCONFIG /ALL') do (
 set line=%%a
 for /f "Tokens=*" %%x in ('@echo %%a ^|find "Ethernet adapter "') do set OK=N
 for /f "Tokens=*" %%x in ('@echo %%a ^|find "%LAN%"') do set OK=Y
 if "!OK!" EQU "Y" for /f "Tokens=*" %%x in ('@echo %%a ^|find "DNS Servers . . . . . . . . . . . : "') do set DNSIP=!line:~36!
set DefaultAgingState=N
set qry=reg query "\\%DNSIP%\HKLM\SYSTEM\CurrentControlSet\Services\DNS\Parameters" /V DefaultAgingState
for /f "Tokens=1-3" %%a in ('%qry%^|find /i "DefaultAgingState"^|find /i "0x1"') do set DefaultAgingState=Y
set qry=reg query "\\%DNSIP%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server\Zones" /s
for /f "Tokens=*" %%a in ('%qry%') do (
 set line=%%a
 set work=!line:\DNS Server\Zones\=!
 set Aging=N
 if "!line!" NEQ "!work!" set Zone=!line:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server\Zones\=!
 for /f "Tokens=1,3" %%x in ('@echo %%a^|find /i "Aging"^|find /i "0X1"') do (
  set Aging=Y
  @echo "%DefaultAgingState%","!Aging!","!Zone!" 

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.