PowerShell is a powerful command line tool that let’s you do all the cool things that GUI can’t do. Here, I will show steps to install Domain Controller in Server 2012 using Windows PowerShell. The installation is similar to GUI installation but involves PowerShell cmdlets.
Install Domain Controller in Server 2012 using Windows PowerShell
Make sure you have installed Server 2012. Other important pre-configurations are static IP address and computer name. Here is our scenario.
We will install domain controller in MBG-DC1 using Windows PowerShell which has static IP address of 192.168.80.1. So, let’s get started.
Step 1: Check AD DS Role Availability
At first, let’s check the status of AD DS role. Open Windows PowerShell and hit the following cmdlets.
PS C:\Users\Administrator> Get-WindowsFeature AD-Domain-Services
We can see it is available, so let’s install AD DS role by typing following cmdlets.
PS C:\Users\Administrator> Install-WindowsFeature -Name AD-Domain-Services
You will see following screen after finishing the install of the AD DS feature.
Step 3: Perform Prerequisite Checks
Before promoting the server to DC, we can perform some checks to ensure everything is OK. Let’s do the test at forest level at first.
PS C:\Users\Administrator> Test-ADDSForestInstallation
Now, let’s perform domain level test.
PS C:\Users\Administrator> Test-ADDSDomaininstallation
Now, test the domain installation at DC level.
PS C:\Users\Administrator> Test-ADDSDomaControllerIninstallation
Step 4: Promote Server to Domain Controller
To promote the domain controller, paste the following cmdlets in you notepad and create a script.
# # Windows PowerShell script for AD DS Deployment # Import-Module ADDSDeployment Install-ADDSForest ` -CreateDnsDelegation:$false ` -DatabasePath "C:\Windows\NTDS" ` -DomainMode "Win2012" ` -DomainName "mustbegeek.com" ` -DomainNetbiosName "MUSTBEGEEK" ` -ForestMode "Win2012" ` -InstallDns:$true ` -LogPath "C:\Windows\NTDS" ` -NoRebootOnCompletion:$false ` -SysvolPath "C:\Windows\SYSVOL" ` -Force:$true
PS C:\Users\Administrator\Desktop> Set-executionpolicy remotesignedCopy the script in notepad and then save as InstallDC.ps1. Then type following cmdlet to change the PowerShell execution policy and execute the script.
PS C:\Users\Administrator\Desktop> .\InstallDC.ps1
You will see following messages during the install. After the install the server will restart. Domain controller has successfully been installed. You can now create user accounts, computer accounts, etc. to manage your domain environment.