This is part of my series on building a virtual lab for use with SQL Server and Windows. You can see the entire series here: Building a Virtual Lab with Hyper-V.
The big thing in setting up a domain is to enable you to connect multiple machines together, experiment with things like Powershell Remoting, AlwaysOn, etc.
There are a couple things you need to do here. The first is to install a domain controller on one of the VMs, and then you need to join the remaining computers to the domain. This isn’t that hard, and I’ll show you two ways to do this: the GUI and PoSh.
Create a Domain Controller
I followed instructions to build a domain from TheSQLPro, since that was the first, and simplest instruction I had. I connected to my ServerCore installation named DenverDC and ran this:
Install-windowsfeature -name AD-Domain-Services
Then
Install-ADDSForest –DomainName “SSCLAB.LOCAL” -DomainMode Win2012 -DomainNetbiosName “SSCLAB” -ForestMode Win2012
I entered both of these from Powershell and restarted the VM. I then ran a
Get-ADDomain
and as you can see, I have a domain set up on this machine.
Joining the Domain from the GUI
The first step is to be sure that you have connectivity between your machine and the DC. I had to ensure I could ping back and forth, both by IP and computer name. I also made sure to set my DNS to the domain controller. In my case, this was the DenverDC at 192.168.1.200.
Once I was fairly sure I had networking down, I went to the control panel on one of the machines. I went to the computer properties and clicked the "Change Settings" link.
From there, I had the basic properties. As you can see below, I was in a workgroup. The first thing to do is click the "change" button.
Once that’s done, you have the workgroup/domain set of radio buttons. I clicked the domain item and entered the name of my domain.
You get a credential box where you need to enter credentials. I believe these are the DC level credentials. For this lab, I have the domain and local administrators all using the same user/password (Administrator/mypassword) and entered that.
If networking is working, it should take a minute and then you’ll get this:
As soon as you click OK, you’ll get told this requires a reboot. It does, so restart.
Once you restart, if you go back, you should see that you are in the domain in the computer properties.
Joining from Powershell
I found this cmdlet that worked for me.
Add-Computer -DomainName "SSCLab.Local"
Once I typed this in, I got a dialog box asking me to enter the administrator credentials. I did that and it worked. I had to reboot with a restart-computer.
And we’re working
Errors
I did get an error on one of my VMs. It was error 0x21C4 on a Server Core installation. When I looked that up, I got a duplicate SID error. I had sysprep’d the machines, but perhaps I broke something. In any case, I re-ran sysprep, reset the network config, renamed the computer, and then joined the domain as noted above.