Solved

need assistance with a DNS zone update script

Posted on 2014-10-23
7
179 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Resolve DNS query failed errors for Exchange
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 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