Solved

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

Posted on 2008-10-27
7
1,831 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
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…
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…

732 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