In my lab, I often have the need to quickly set up various servers from scratch. One type of server is an Active Directory Domain Controller. So I slapped together a simple script to completely automate (light touch) the process of setting up a complete AD DC in a new forest. I also did the same for a second DC in an existing forest, but that’s a story for another post.

This will create the VM in Hyper-V, configure it, install all the roles, and do dcpromo. I’m sure there are better ways of doing this, but it fits my needs for now.

What you need before you start, is an ISO of Windows Server 2019 with an autounattend.xml file on it to do the OSD. I’m not going to go into how to make an autounattend XML, as there are many other resources available on that subject online.

 

So this script runs exclusively on your Hyper-V host, nothing runs inside the VM.