Solved

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

Posted on 2008-10-27
7
1,796 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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 

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

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
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 to another domain controller. Log onto the new domain controller with a user account t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

919 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

21 Experts available now in Live!

Get 1:1 Help Now