Chapter 14. Managing DNS Programmatically

"It's MY opinion that you never think AT ALL," the Rose said in a rather severe tone.

In the last chapter, we reviewed the dnscmd utility, which can be used to manage a Microsoft DNS Server from the command line. But what if you want more control over automating your DNS environment with scripts? Until recently, your only option would have been to run dnscmd from within batch files or from VBScript or Perl scripts. In fact, the lack of a good DNS API has always been a big shortcoming of Microsoft's DNS solution. Starting with Windows 2000, Microsoft answered the call by providing a Windows Management Instrumentation (WMI) DNS Provider. WMI is Microsoft's API of choice for managing and monitoring Windows-based systems and services. With the WMI DNS Provider, you have complete programmatic control over the Microsoft DNS environment, much like you do with dnscmd from a command line.

In this chapter, we cover the WMI DNS Provider by providing real-world scripts that should serve as good examples to get your automation efforts jumpstarted. If you need a more detailed introduction to WMI, check out Alain Lissior's books from Digital Press: Understanding Windows Management Instrumentation (WMI) Scripting and Leveraging Windows Management Instrumentation (WMI) Scripting.