Solved

DNSadd and DNS delete commands

Posted on 2011-02-27
4
946 Views
Last Modified: 2012-05-11
Hi,
I have been trying to find the exact dnsadd and dnsdel commands - couldn't
Can any one please write the exact dns commands

Above part is most important. But if you can please answer below aswell
If I have a comma saperated text file with three parameters and row delimeter ';'
IP                    Host                record type
101.2.4.3        testserver       A

Can any please write a code - i think can be done in VB
to read the file and execute the dnscmd command?
or can it even be done just by BAT files
Basically if I drop a text file with may be particular extension at dir location.
How can we read the file and create dns records from it
not sure but badly in need of help

Big basket of thanks :)
   
0
Comment
Question by:SameerMirza
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
ID: 34994361
Hi Sameer,

Check following batch script if this satisfy your requirement.

You need to change variables (DNSServer, DNSZone) values inside the script. Furthermore you require DNSRecords.txt file where you will list all node names with corresponding IP address (space separated).

Hope this helps!
Farhan



@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION

SET DNSServerIP=192.168.1.1
SET DNSZone=MYDOMAIN.COM.PK
SET RecordType=A

FOR /F "Tokens=1-2" %%A in ('TYPE DNSRecords.txt') DO (
	DNSCmd.exe !DNSServerIP! /RecordAdd !DNSZone! %%A !RecordType! %%B)

Open in new window

0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 34994719
Have you tried with DNSCMD from Windows Support Tools? Using this tool it's easy and you can simply script all :)

Example:

Create
dnscmd DNSServerName /RecordAdd DNSZoneName HostName RecordType IPAddress

dnscmd mydns01 /RecordAdd mydomain.local testserver A 101.2.4.3

Delete
dnscmd DNSServerName /RecordDelete DNSZoneName HostName RecordType /f

dnscmd mydns01 /RecordDelete mydomain.local testserver A /f

Regards,
Krzysztof

0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 34994732
@farhankazi: I'm sorry I didn't check your script code :( That I put the same code here

@SameerMirza: please skip my answer

Krzysztof
0
 

Author Closing Comment

by:SameerMirza
ID: 35166614
thanks alot. I am very sorry for late reply :/
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
How to record audio from input sources to your PC – connected devices, connected preamp to record vinyl discs, streaming media, that play through your audio card: Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10 – both 32 bit & 64.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

815 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

12 Experts available now in Live!

Get 1:1 Help Now