Install ADDS using PowerShell
Why we need to install Active Directory Domain Services using PowerShell?
When we are running Microsoft Servers we can install server as a server core.Which means it doesn't have a GUI and we can get more benefits such as reduce services,reduce management and reduce attack surface interface.To running an Active Directory, a server core is the most suitable way, but to install Active Directory on server core with earlier versions we had to create Active directory unattended answer files.
With Server 2012/2012 R2 , there is a new PowerShell module inbuilt which has named as ADDS-Deployment. This module we can use for installing our Active Directory on server core. Anyway we can switch Win 2012 server core to GUI and GUI to core at any given time.
Steps or install AD using PowerShell
1.First we have to add ADDS role using PowerShell. For that we can use Install-WindowsFeature power shell CMDLET:
2. We can use ADDSDeployment power shell module for install our Active Directory.To get all the available commands in ADDSDeployment we can use Get-Command -Module ADDSDEployment command:
Add-ADDSReadOnlyDomainControllerAccount
Using this account we can create read only domain controller in the ADDS
Install-ADDSDomain
Using this command we can install child domain or new domain in a existing forest
Install-ADDSDomainController
Using this command we can install Additional Domain Controller in a existing domain
Test-ADDSDomainControllerInstallation
This will check for the prerequisite for install the domain controller
Test-ADDSDomainControllerUninstallation
This will check for the prerequisites for uninstall the domain controller
Test-ADDSDomainInstallation
This will check for the prerequisites for install new domain
** **
**Test-ADDSForestInstallation
**
This will check for the prerequisites for install new domain
Test-ADDSReadOnlyDomainControllerAccountCreation
This will check for the prerequisites for adding read-only domain controller account
Uninstall-ADDSDomainController
This will check for the uninstalling ADDS Domain Controller
To install new forest in our network we can use Install-ADDSForest command
We can take below example for install new forest
Install-ADDSForest -DomainName xyz.local -DomainMode Win2012R2 -ForestMode Win2012R2 -DomainNetbiosName xyz -SafeModeAdministratorPassword (convertto-Securestring -AsPlainText -Force asd@123) -Installdns