Over the years I’ve tested many aspects of Microsoft’s Active Directory. Sometimes those tests resulted in unforeseen consequences on my production environment. When Hyper-V came along it was the perfect tool to test different environments including Active Directory.
In this post I’ll walk you through setting up a simple environment with one Windows Server 2022 running AD, DNS and DHCP. We’ll also install two clients (Windows 10 and Windows 11.)
This tutorial requires no experience with Active Directory or Hyper-V. If you are an IT expert you might want to skip to the networking section.
Let’s first go over the requirements. Some of these are just recommendations based on my own personal experience.
Requirements:
- Windows 10/11 Enterprise, Pro or Education
- At least 16GB of RAM (32GB or more is better)
- i7 Processor w/2 cores (this will probably work on an i5 processor)
- TPM option on processor
- Enough free diskspace (probably 100GB depending on what you’ll be testing)
- A decent Internet connection for downloading ISO files
Steps Required To Build Out This Test Lab
- Install Hyper-V Feature
- Setup Virtual Network
- Download ISO Images
- Setup Windows Server 2022 Virtual Machine
- Install AD, DNS and DHCP services on server
- Setup Windows 10/11 Virtual Machines
- Connect Windows Clients to AD and Test
Installing The Hyper-V Feature On Your Host Computer
Navigate to Settings and search for “Windows Features”. Choose Turn Windows features on or off
Choose the Hyper-V feature which will automatically choose the sub features below. Then hit OK. At this point I believe you’ll need to reboot. (slept a few times since enabling the feature)
Setup The Virtual Network
We’ll use Powershell to create a switch and NAT routing. New-VMSwitch -SwitchName “LabSwitch” -SwitchType Internal
Open a Powershell prompt and type the above command to create a virtual switch. (You can change LabSwitch to anything you want.)
NOTE: If you get an execution error change your execution policy by typing “set-executionpolicy -ExecutionPolicy RemoteSigned”New-NetIPAddress -IPAddress 192.168.123.1 -PrefixLength 24 -InterfaceAlias “vEthernet (LabSwitch)”
The above command creates our NAT gateway for the virtual switch. (“LabSwitch” and the IP Address “192.168.123.1” can be changed. Just make sure they don’t conflict with your network.) New-NetNat -Name LabSwitchNetwork -InternalIPInterfaceAddressPrefix 192.168.123.0/24
The above command creates the subnet for our test environment. As before you can change the subnet and network name.
That’s it for creating our virtual network. You can now close out Powershell.
Download Required ISO Images
Download the following for this lab.
Windows Server 2022 https://info.microsoft.com/ww-landing-windows-server-2022.html This download is almost 5GB so I hope you have a fast connection!
Windows 10 https://www.microsoft.com/en-us/software-download/windows10 Unfortunately, you have to download an .exe and run that to get the actual ISO image.
Windows 11 (doesn’t require running the .exe install app. Make sure you choose “Download Windows 11 Disk Image (ISO)”) https://www.microsoft.com/software-download/windows11
Setup Windows Server 2022 Virtual Machine
Now that we have the ISO downloaded for our virtual machine let’s launch Hyper-V Manager. Open the search bar and type “Hyper-V” and launch it.
NOTE: If you’re comfortable creating virtual machines you can skip to AD, DNS and DHCP config.
Let’s create the Windows Server 2022 virtual machine by right clicking the machine name then choose “New” and “Virtual Machine…”
Next, let’s choose a Name and Location for our virtual machine files.
Next, we’ll leave it Generation 2. (Generation 1 is for BIOS and can’t be changed later.)
Set memory to 4192 or higher and use Dynamic Memory.
Choose the network we created earlier.
Setup your drive for this VM.
We’ll install the OS later. We need to make some changes to the config before proceeding. Hit Finish here.
We now have the initial settings complete. Right mouse click the LabServer and choose Settings… to start the OS install.
I’m not going to bore you with screen shots of every setting change so here’s a list below.
- Change processors from 1 to 2
- Under SCSI Controller add DVD Drive and point Image file to downloaded ISO file
- Choose Apply at bottom
- Goto Firmware and set order so DVD loads first
- Hit OK to exit
After exiting the settings goto the LabServer and right mouse click and choose Connect… This will open up the virtual machine before starting it.
After the screen opens for the VM choose Start (you’ll need to hit Enter several times so it loads the ISO.)
You should get this as your first screen after the ISO loads. Choose Next then Install Now.
Next you’ll choose Windows Server 2022 Standard Evaluation (Desktop Experience)
After this screen you’ll accept the license terms and hit Next.
On the next screen you’ll choose Custom: Install Microsoft…
Hit Next to accept the default for installing the OS on the virtual disk.
Now our Windows Server 2022 is installing. Sit back and watch it do it’s magic! (this will take some time depending on the speed of your computer. Might be a good time for a coffee break)
Now that the OS is installed we need to setup a password for the Administrator. Make sure it’s something you’ll remember!
Install AD, DNS And DHCP Services On Server
We’ve now installed Windows Server 2022 as a virtual machine on Hyper-V. Our next step is to add the roles Active Directory, DNS and DHCP on the server.
When you login to the server you should see the Server Manager Dashboard as shown below.
Before we add any services we need to first setup networking.
Once you get into the Ethernet settings we need to setup the static IP address, Gateway and Subnet. To do that Open Ethernet, Properties and open the Properties for Internet Protocol Version 4.
Enter IP settings exactly like I have below unless you decided on a different subnet then use those settings. After you make the changes click OK then exit out of the Network settings section until you get back to the Local Server Dashboard.
From the Local Server Dashboard you should see the Computer name. Unfortunately, it didn’t use the name we gave the virtual machine so let’s change that.
Click on the Computer Name then choose Change and type in the name you want. I’m using LabServer and hit OK.
After you save the changes and navigate back to the Dashboard choose Add roles and features from the main menu. Click Next until you Select Server Roles and choose Active Directory Domain Services.
Once you select Active Directory Domain Services you’ll see the screen below. Just click on Add Features.
You’ll need to click Next until you get to the screen below. From here just click Install.
After clicking Install you see the installation progress. Wait until the installation is complete before clicking Close.
After you hit Close you’ll be taken back to the Dashboard. Notice the warning sign at top right. Click that then choose Promote this server to a domain controller.
Follow the steps below to configure your new domain.
On this next screen you’re required to enter a recovery password. Since this is a lab you can give it same password as local administrator password you used when setting up the server. Notice we checked Domain Name System (DNS).
Disregard the warning message on this next screen. Just choose Next.
Continue to hit Next until you get to Prerequisites Check screen. You can disregard warnings and hit Install.
If the install was successful the system will reboot and setup the newly formed domain.
You should get a login screen with the new domain name. Go ahead and login.
Now that we have Active Directory and DNS setup we need to add the DHCP role. From the Server Dashboard choose Add roles and features and click Next until you see the Server role DHCP Server and choose it. After choosing it hit the Add Features button. Hit Next twice then hit Install. Hit Close when it’s finished installing. (similar to adding Active Directory Services role)
Same steps to complete the Active Directory Service, click on warning icon then choose Complete DHCP configuration.
Click Next then hit Commit then Close.
We now have AD, DNS and DHCP installed. Now we just need to tweak the DHCP settings. We can do this by clicking on Tools from the Dashboard and DHCP.
After the DHCP console opens right mouse click on IPv4 and choose New Scope.
Hit Next then Name your scope. Hit Next again and setup your starting and ending IP addresses.
Continue hitting Next until you get to the Router setting. Enter that as below then it Add and hit Next.
Finally at the finish line. Hit Next to activate the scope. Hit Finish after this screen.
You have now completed the setup on the server, Active Directory, DNS and DHCP. Next we’ll start installing the clients.
Setup Windows 10/11 Client Virtual Machines
Now that we’re done setting up the LabServer we can go back to Hyper-V and setup our first client. Let’s start with Windows 10 (most of these steps are identical on Windows 10 and 11)
Open the Hyper-V Manager if you haven’t already and right mouse click the Host name and choose New then Virtual Machine…
You’ll hit Next then enter the the following settings.
Name of your virtual machine (I called mine Client10), set the location of your VM files, choose Generation 2, memory is 4192 w/Dynamic Memory checked, Connection is LabSwitch, virtual disk size is 40GB
Then choose to install operating system later then hit Finish.
Now go back into the Client10 settings and change the following:
Processors = 2, select SCSI controller and add DVD drive and choose Image file (ISO for Windows 10), then it Apply. Goto Firmware and move DVD Drive to top of boot list and hit Apply again.
NOTE: (If you plan to test using Bitlocker you will need to check Enable Trusted Platform Module under Security.)
We’ll do the same as we did with the Server VM setup. Right mouse click the Client10 VM and choose Connect. Hit Start and start hitting the Enter key until you see the DVD has started to install.
We’ll choose Windows 10 Pro for the OS type. (Education type will also work)
After you hit Next accept the license agreement and choose Custom for install type and hit Next at install location.
Your Windows 10 client will start installing the necessary files at this point.
Now that Windows 10 is installed you’ll need to tell it you’re connecting to a domain. On this screen choose Set up for an organization and then hit Next.
Now we need to choose Domain joined instead and then hit Next.
Below, enter a username and hit Next.
The next screen will ask for a password and then hit Next again. After this screen you’ll be asked some security questions.
After the security questions, accept the defaults on the next screen and skip the experience page. Also, skip the Cortana setup.
You should now be back at the login page after the initial settings. Enter the password you setup earlier. At this point we’re done installing Windows 10.
As mentioned before Windows 11 VM setup is almost identical to the Windows 10 VM setup except for one setting. You need to choose Enable Trusted Platform Module otherwise the install will fail. If you’re testing requires Bitlocker you’ll need this enabled anyway.
I’m not going to show every single step since it is almost the same as Windows 10, but I will show the screens that are different.
At the setup screen for sign in choose Sign-in options.
The remaining settings should be what you had in the Windows 10 setup. That concludes setting up our clients.
Connect Windows Clients To AD And Test
We’re so close! Before we access our clients let’s add a test account to AD. First open the virtual machine LabServer and goto Active Directory Users and Computers.
The next screen will ask for a password. Also, you can set the password options. For testing I usually check Password never expires. After that hit Finish and your user is setup and ready to test.
Now that our test user is setup let’s join these clients to the domain. If you don’t have your Windows 10 client running go ahead and start it up. Use the account you entered when setting up Windows 10.
Now that we’re logged in we need to join this client to the domain. From the search bar type sysdm.cpl and Enter.
You’ll notice I misspelled the domain. It should be labdomain.local. Make sure you check your work before hitting Ok.
After hitting OK you’ll be prompted for a login. You can use the Testuser we setup earlier or the domain Administrator account. You should then see the message below. You’ve just joined your Windows 10 client to the domain!
After Windows 10 reboots you’ll have the option to login to the domain. Login as Testuser to verify it works. If you get an error when logging in login as the domain administrator first then login as Testuser.
Now back to Windows 11 client. If you haven’t already power up that vm and login using same username and password you used when you setup Windows 11.
Once logged in you’ll run the same command to join the domain, sysdm.cpl.
After running sysdm.cpl you’ll see the same screens you did for Windows 10, choose Change then enter the domain labdomain.local and then hit OK where you’ll enter the Testuser login credentials to add the Windows 11 client to the domain.
Login to the domain. If you get the below error logout and back in as the domain administrator.
Now if you logout the administrator account and back in as the TestUser it should work!
The real beauty in creating virtual machines is that you can snapshot them after creating so if you break something during testing you can just revert back to a previous state. To do this open Hyper-V Manager, right mouse click your lab server or clients and choose Checkpoint. From there you can name your checkpoint anything and revert back to it at anytime.
Conclusion
In this post we created a virtual test lab consisting of a Windows 2022 server with Active Directory, DNS and DHCP installed. We created two clients; Windows 10 and Windows 11 and joined them to the domain. I hope this post was helpful.