Solved

Looking for a script to add multiiple DNS forwarders to a number of Microsoft DNS servers

Posted on 2008-10-27
7
1,789 Views
Last Modified: 2010-07-27
Can someone post a script that will allow me to add a new DNS conditional forwarders to a group of Group of Domain controllers. I would like to use a .CSV or .TXT input file to define 20+ DNS servers that the script can loop through.
I can use either DNSCMD or VBscript, whichever is easier.

I did find this article, http://codeidol.com/active-directory/active-directory/DNS-and-DHCP/Configuring-Forwarding/
however, im not sure how to modify the example scripts to reference a .csv or .txt input file.

thx in advance

M
0
Comment
Question by:siber1
  • 4
  • 3
7 Comments
 
LVL 38

Expert Comment

by:Shift-3
ID: 22815840
You can loop through entries in a text file with the FOR /F command as below.  Replace all instances of %G with %%G if you are including it in a batch script.


for /F %G in (computerlist.txt) do dnscmd %G /resetforwarders 10.22.3.4 10.22.3.5

Open in new window

0
 

Author Comment

by:siber1
ID: 22817941
HI shift, I just tested that in my home lab and it didn't add the forwarders.
I tried this script, but it is not working. what should I change:
@echo off
setlocal
 
set list=c:\list.csv
for /F %%G in ("%list%") do dnscmd %%G /zoneadd test.com /forwarder 10.1.10.1 10.1.10.2
 

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
ID: 22817973
The quotes around %list% are the problem; they're causing it to be interpreted as a text string.  You can avoid this by using the usebackq parameter.

@echo off

setlocal

 

set list=c:\list.csv

for /F "usebackq" %%G in ("%list%") do dnscmd %%G /zoneadd test.com /forwarder 10.1.10.1 10.1.10.2

Open in new window

0
 

Author Comment

by:siber1
ID: 22821042
thx Shift, one last question. do you know if there is a way to delete all conditional forwarders using dnscmd or a VB script?

thx much

M.
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 22821137
dnscmd <server> /resetforwarders should do it.
0
 

Author Closing Comment

by:siber1
ID: 31510464
thx again
0
 
LVL 38

Expert Comment

by:Shift-3
ID: 22822783
Wow, a B.
0

Join & Write a Comment

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now