HOWTO : Creating new Active Directory forest with Powershell

0 Flares 0 Flares ×

I’ve seen many howtos, manuals how to install Active Directory domain, but they were always GUI based, as example I’ll put just 2 links, one is Technet and second is Petri website. So in this post I’d like to present how to install and configure basic AD forest using Powershell, it requires just a few input data and 2 powershell commands.

So let’s start with the input data. To create new AD forest and domain, I’ll need at least: domain name, domain NETBIOS name, domain and forest functional levels and database, logs and sysvol paths. 

So let’s define them, I have chosen functional forest and domain functional levels : Windows 2012 R2, in my case variables will be as following

Before I can start adding new Active Directory forest, I have to install AD-Domain-Services windows feature and I want to install AD management tools as well.

So PS command for this will be :

This feature installation does not require reboot, so I can proceed with new forest creation. The PS command I will use is  Install-ADDSForest with the parameters I defined in the begining and few additional options :

  • -InstallDNS – to install DNS server
  • -confirm:$false – to not have to type “yes” while running PS command
  • -NoRebootAtCompletion – not to reboot when PS command finished, I will reboot server manually
  • -SafeModeAdminPassword – to define safe/recovery mode password. But I don’t have the password yet, I can request the password using PS

So now I have all the necessary to install new AD forest, so command for installation goes like this

After command finishes, I can check if everything is ok and reboot the server, using of course Powershell 🙂  Restart-Computer -force

I have put all the commands I used to the script below to have it all together

This small script can be enriched, by the Test-ADDSForestInstallation, Test-ADDSDomainInstallation and Test-ADDSDomainControllerInstallation commands, which verify if forest, domain and domain controller can be safely installed. This I will keep for your own creativity and imagination.

0 Flares LinkedIn 0 Google+ 0 Facebook 0 Twitter 0 0 Flares ×

Leave a Reply

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