Solved

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

Posted on 2008-10-27
7
1,842 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

632 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