Solved

need assistance with a DNS zone update script

Posted on 2014-10-23
7
167 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
  • 4
  • 3
7 Comments
 
LVL 28

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 28

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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 28

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 28

Expert Comment

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
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…

759 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

26 Experts available now in Live!

Get 1:1 Help Now