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
Solved

Need help with dnscmd.exe

Posted on 2007-12-01
4
910 Views
Last Modified: 2010-08-05
Environment: Windows 2003 server, AD integrated DNS

Hi there:
I'm having a devil of a time tyring to do a delete/replace all A and www records in 1000+ DNS records for our websites (the IIS server has moved to another IP address (67.155.1.103)) and I'm also trying to set up a new DNS server.  I am on the new DNS server and all DNS zones have been set up, but they have the old A and www records pointing to the IP address of the old IIS server.
I have written two batch files and I am executing one against the other.
One .bat program has all the website names and I am doing a  
for %%1 in (
domain1
domain2
...etc.
) Second_bat_file

The second .bat file against which the first program is executing has the following dsncmd commands:

dnscmd /recorddelete %1 @ A www /f
dnscmd /recorddelete %1 @ A 67.95.76.244 /f
dnscmd /recordadd %1 @ A www  67.155.1.103 /f
dnscmd /recordadd %1 @ A 67.155.1.103 /f

From the commands, you can see I am trying to delete the A and www records in each DNS zone and replace them with new a and www records.

When I run the program batch file against this second one, it keeps giving me invalid syntax or missing syntax errors . The program goes through all the websites (and gives all the errors), so I don't see a problem with the first .bat file that contains the for/do program and the domains.  The problem appears to be in my syntax in the second .bat file that contains the dnscmd lines. What am I doing wrong? I have tried all kinds of combinations and nothing works.
Thanks

Open in new window

0
Comment
Question by:PWyatt1
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:oBdA
ID: 20391474
The error is in your first script.
The "for" command has to be used with letters from a to z or A to Z, and you didn't pass the variable to the second batch script, either.

for %%a in (domain1 domain2 ...) do call SecondFile.bat %%a

Open in new window

0
 

Author Comment

by:PWyatt1
ID: 20391841
Thanks. So I replace the "1" with an "a" in the first script. Does the "a" variable also have to appear in the second script. If so, where does it appear in each dnscmd line?
Thanks
0
 
LVL 84

Accepted Solution

by:
oBdA earned 125 total points
ID: 20391884
The "%%a" variable is only visible in the "for" loop.
It is then passed using the command line to the second batch file (and the first command line argument in the second batch is then %1).
0
 

Author Comment

by:PWyatt1
ID: 20392095
Excellent! Thanks for the help. I'm assuming I can have multiple dnscommand line arguments in the second batch file.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
Resolve DNS query failed errors for Exchange
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

856 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