Batch Script to Add Multiple Records at Once to DNS Server.
Adding multiple host records to a DNS server is something a Network Administrator wouldn’t have to do on a regular basis. And that’s because computer register with DNS server after receiving an ip address from DHCP in something called Dynicamic DHCP in which the DHCP registers the client on the DNS server; however, there are situations in which you would have to enter many host names into DNS. For example, host are not registering for some reason or you’re migrating the server to a newer server. Assuming you backup everything, the migration should be a breeze, but there are unexpected situation. Well this small script in MSDOS Bath reads from a text file containing host mappings in the form of Hostname Ipaddress. and import them into the DNS server.
text file containing hosts, save to C:\dnsHost.txt
computer00 192.168.10.100 computer01 192.168.10.101 computer02 192.168.10.102 |
batch script
for /f "tokens=1-2" %i in (c:dnsHost.txt) do ( dnscmd %LOGONSERVER% /RecordAdd testenv.local %i A %j ) |