Solved

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

Posted on 2008-10-27
7
1,810 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
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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