Solved

DNSadd and DNS delete commands

Posted on 2011-02-27
4
940 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Resolve DNS query failed errors for Exchange
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

895 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

14 Experts available now in Live!

Get 1:1 Help Now