I sometimes need to delete large blocks of records from one of my DNS zones. You'd think that you could simply highlight a group of records in the Microsoft Management Console (MMC) DNS snap-in and press Del, but the DNS snap-in lets you delete only one record at a time. The foundation of any good Active Directory (AD) is a good DNS infrastructure. But unlike many other Windows 2000 tools, Win2K's DNS server isn't very controllable from the command line, so scripting common tasks is difficult. Although the dnscmd.exe tool ships on the Win2K Server CD-ROM, that tool isn't very complete.
However, the Microsoft Windows 2000 Server Resource Kit Supplement One includes a complete set of DNS command-line tools. This toolset is in two parts. One part is a Windows Management Instrumentation (WMI) object for controlling the DNS server. The second part consists of three Perl scripts that use the WMI object to control DNS servers, zones on those servers, and records in those zones. You can use those Perl scripts to tell a DNS server to do just about anything that you can tell it to do from the GUI—no obvious capability seems to be missing.
Because the tools are all scripted, you can take them apart and put them back together to do any DNS-related task—all without writing a single line of Perl. Dnsserver.pl (.pl is a common extension for Perl scripts) controls overall DNS server properties, such as starting or stopping the DNS service, clearing the server's DNS cache, and displaying the zones on the server. Dnszones.pl lets you work on a particular zone on a particular server. This script lets you do tasks such as creating a new zone, deleting an existing zone, or converting a zone from a standard primary zone to an AD-integrated zone. You can also use the script to enable or disable dynamic DNS (DDNS) updates on that zone and control whether the zone accepts updates from anyone and whether the updates must be Kerberos-secured. Dnsrecord.pl lets you operate within a zone to create, modify, or delete records. Because they're built atop WMI objects, the scripts work remotely as well as locally, so you can run a script on one computer to control a DNS server on another computer.
I'd need several columns to show you the syntax for these three scripts. However, I do want to point out that you need to do a little preparation to make them work. First, install Supplement One on the computer that you'll run the Perl scripts from. That step installs the Perl interpreter and a required Perl module that tells Perl how to control WMI. But Supplement One's standard install routine doesn't install the module where Perl can find it. To install that module, create the directory \perl\site\lib\w2rk and copy wmi.pm from \program files\resource kit to the new directory.
Next, prepare the DNS server that you want to remotely control. You don't need to install Perl on that server, but you do need to install the WMI object that controls Perl. You'll find three files in the Supplement One CD-ROM's \apps\dnsprovider folder: dnsprov.dll, dnsschema.mof, and dnsprovider.chm. Copy those files to any directory on the DNS server (I put them in a folder I named Dnsfiles). Then, at a command line on the DNS server, change to the folder that you just put the DNS WMI files into and type two lines:
mofcomp dnsschema.mof regsvr32 dnsprov.dll
You should get a confirmation after those files are installed. Then, take a peek at dnsprovider.chm—it's a Help file (you'll find it in the resource kit directory) that contains VBScript examples of how to use the Perl scripts.