PowerShell: Creating Domains and Domain Controllers

KB ID 0001400

Problem

I needed to spin up some Windows 2016 Servers, and a domain to do some testing. I have promoted hundreds maybe thousands of domain controllers, so I wondered if this time I could do it with PowerShell. It’s actually easier than using the GUI!

Solution

If you were doing this in Server Manager, you would have to add the role first, and PowerShell is no different;

Install-WindowsFeature AD-Domain-Services -IncludeManagementTools

PowerShell Add AD Domain Services

Then promote the server to a new DC in a new forest;

Install-ADDSForest

PowerShell New Forest

Supply the new domain name and the recovery password. Select ‘Y’ to reboot, go and have a coffee, when finished you will have a new DC in a new domain, ready to log into.

Related Articles, References, Credits, or External Links

NA

Author: PeteLong

Share This Post On

3 Comments

  1. Thanks!
    will this powershell “version” of the process will also install the DNS role and everything else that is done with the gui “version” of the procerss?

    Post a Reply
    • Yes of course, you can add some extra flags to change things but with the command you will get all the ‘defaults’ 🙂

      Pete

      Post a Reply

Leave a Reply to PeteLong Cancel reply

Your email address will not be published. Required fields are marked *