Configure non-integrated DNS zones with PowerShell
I've been looking at scripting out the build out of my Azure Lab so I can build it, use it for a purpose then rip it down and start again to use it again. One of the scripts that I've pulled together is configuring non-integrated DNS Zones with Powershell both on a local server and a remote server. The script I've created assumes that the DNS role is installed on your servers and that PSRemoting is enabled on your servers. If you are unsure how to enable PSRemoting please refer to my previous blog post - Run PowerShell Commands on Remote Computers
My NonIntegratedDNSInstall.ps1 script helps to install non-integrated DNS zones onto three servers. One acting as the primary and two act as the secondary servers. There are some information within the script that requires configured before the script is run and requires some input during the script execution. Here is a break down of the script.
This first section is where the inputs from the engineer running the script are declared and has the static inputs of the non-integrated DNS zones that need to be created:
The next section of the script declares the script that will be run on the remote server(s) and collects credentials for connecting to the remote server(s):
Now that the script has created the first copy of the zones the script looks to create the zone copies on the remote servers. The script checks to see if a third server is being used or not and executes the commands accordingly.
Part of the script is to remove the file where the remote credentials are stored, and closing off the remote sessions created correctly.
An output is also displayed for the user to show a successful completion or not. Below is a demo on the script running with two servers: