?
Solved

need assistance with a DNS zone update script

Posted on 2014-10-23
7
Medium Priority
?
182 Views
Last Modified: 2014-10-23
hello, can someone provide a script that we can use to update a remote DNS zone with records.

here is the scenario, we have a team in one region that adds machines to the domain, we have another stub zone server in a different region that we have to update with the new systems added [due to a NAT requirement]

we need a script that they can run that will prompt to enter the name & IP address, and from there update the DNS zone on a remove standalone DNS server.

many thanks!

S.
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 29

Expert Comment

by:becraig
ID: 40400993
You can probably just pipe the values into dnscmd

dnscmd [<ServerName>] /recordadd <ZoneName> <NodeName> <RRType> <RRData>

Do a  Read-host for the values you need to populate.

$val1 = Read-host "Please Enter the hostname"
$val2 = Read-Host "Please enter the ip address"
#Then run the dns cmd
#I am guessing server name will be hardcoded as probably the record type
dnscmd DNSSERVER1 /recordadd domain.local $val1.domain.local. A $val2

Open in new window

0
 

Author Comment

by:siber1
ID: 40401017
hello becraig, when I run the script I get this confirmation:
Add A Record for . at mydomain.com
Command completed successfully.

Open in new window


no record is added to the zone, it looks like perhaps the variables are not being passed correctly?
0
 
LVL 29

Expert Comment

by:becraig
ID: 40401021
ok let us do a write-host for the command for debugging so we can be sure:
$val1 = Read-host "Please Enter the hostname"
$val2 = Read-Host "Please enter the ip address"
#Then run the dns cmd
#I am guessing server name will be hardcoded as probably the record type

write-host "dnscmd DNSSERVER1 /recordadd domain.local $val1.domain.local. A $val2"

dnscmd DNSSERVER1 /recordadd domain.local $val1.domain.local. A $val2

Open in new window

0
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

 

Author Comment

by:siber1
ID: 40401029
interesting, the write-host looks perfect, but it doesn't create the record with the variables.

If I run the line that "write host" provides manually in powershell it creates the record fine

here is what write host displays;
dnscmd impmadc1 /recordadd mydomain.com ztest.mydomain.com. A 10.100.2.30

Open in new window


when I run the script, no record is created, when I run it manually the record creates as expected. thoughts?
0
 
LVL 29

Accepted Solution

by:
becraig earned 2000 total points
ID: 40401052
Let's try this and see:


$val1 = Read-host "Please Enter the hostname"
$val2 = Read-Host "Please enter the ip address"

$cmdval = "dnscmd DNSSERVER1 /recordadd domain.local $val1.domain.local. A $val2"
Invoke-Expression $cmdval  

Open in new window

0
 

Author Closing Comment

by:siber1
ID: 40401054
brilliant. works perfectly. thx much!
0
 
LVL 29

Expert Comment

by:becraig
ID: 40401055
Np glad to help.
0

Featured Post

Ransomware Attacks Keeping You Up at Night?

Will your organization be ransomware's next victim?  The good news is that these attacks are predicable and therefore preventable. Learn more about how you can  stop a ransomware attacks before encryption takes place with our Ransomware Prevention Kit!

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

770 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