Solved

need assistance with a DNS zone update script

Posted on 2014-10-23
7
181 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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 500 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A brief introduction to what I consider to be the best editor for PowerShell.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

690 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