Deploying Windows Server 2012 DC using Powershell


Hey guys,
In this short article I want to show you how to install Windows Server 2012 Domain Controllers and Forests by using the new Powershell cmdlets provided with this Edition. Server 2012 introduced a lot of new features and it has introduced a new way to install and configure Domain Controllers. Installing a new machine using the interface it’s still pretty intuitive so instead, I’ll insist in showing you how to achieve this by using Powershell. Before we can use the new cmdlets to configure our DC, execute the following command to install AD Domain Services:
Install-windowsfeature -name AD-Domain-Services –IncludeManagementTools

To explore newly introduced cmdlets, type in the following:
Get-Command -Module ADDSDeployment

Powershell Domain Controller deployment

There are two situations that can occur when deploying a new Domain Controller:

  • Deploying a DC in a new Forest
Before we can go at the installation part, we’ll need to make sure our new forest will pass the needed requirements. Use the Test-ADDSForestInstallation cmdlet to test the forest installation:

Test-ADDSForestInstallation -DomainName “ppscu.com” -NoRebootOnCompletion

Powershell create new Active Directory Forest

If the operation is completed successfully you can proceed further with the forest installation.
When adding the first Domain Controller to a new Forest, you will need to execute the following:

Install-ADDSForest
 -CreateDnsDelegation:$false `
 -DatabasePath “C:\Windows\NTDS” `
 -DomainMode “Win2012R2” `
 -DomainName “ppscu.com” `
 -DomainNetbiosName “ppscu.com” `
 -ForestMode “Win2012R2” `
 -InstallDns:$true `
 -LogPath “C:\Windows\NTDS” `
 -NoRebootOnCompletion:$false `
 -SysvolPath “C:\Windows\SYSVOL” `
 -Force:$true

You will be prompted to set a DSRM password for the specified forest. Note that the operation will take some time so be patience. The first Domain Controller within a Forest will also be a Global Catalog server.
  • Deploying a DC in an existing Domain
To test weather your forest supports adding the machine as a Domain Controller for your existing Farm, use the following cmdlet:

Test-ADDSDomainControllerInstallation -InstallDns -Credential (Get-Credential
PPSCU\Administrator) -DomainName “ppscu.com”

Once all tests have been completed successfully, execute the following command to add your new DC. Note that you’ll have to change the parameters values according to your needs:

Import-Module ADDSDeployment
Install-ADDSDomainController ‘
-NoGlobalCatalog:$false ‘
-CreateDnsDelegation:$false ‘
-Credential (Get-Credential) ‘
-CriticalReplicationOnly:$false ‘
-DatabasePath “C:\Windows\NTDS” ‘
-DomainName “ppscu.com” ‘
-InstallDns:$true ‘
-LogPath “C:\Windows\NTDS” ‘
-NoRebootOnCompletion:$false ‘
-SiteName “ppscu.com” ‘
-SysvolPath “C:\Windows\SYSVOL” ‘
-Force:$true

To uninstall a DC from a domain, use the Test-ADDSDomainControllerUninstallation and Uninstall-ADDSDomainController cmdlets.
That’s about it for this article folks, hope you will enjoy it. Have a great day!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s