- Active Directory Administration Cookbook
- Sander Berkouwer
- 216字
- 2021-06-24 14:42:07
Promoting a domain controller using Windows PowerShell
For the Active Directory Module for Windows PowerShell, Microsoft has decided to take a slightly different route. Instead of using a single PowerShell cmdlet to promote a domain controller, there are three separate PowerShell cmdlets for each of the three scenarios, as presented as part of the Active Directory Domain Services Configuration Wizard:
![](https://epubservercos.yuewen.com/50F576/19470379008810406/epubprivate/OEBPS/Images/6.jpg?sign=1739052441-lPnFodN4j5dOycVyKbQGJrPNOhEiD64t-0-44dacfd05ad0635e65ef852c1531085c)
To add a domain controller to an existing domain, the simplest script would look like that shown in the following example:
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Import-Module ADDSDeployment
Install-ADDSDomainController -DomainName lucernpub.com
However, to add a domain controller to an existing domain, as you would in the previous three examples, the following script would suffice:
Install-WindowsFeature AD-Domain-Services -IncludeManagementTools
Import-Module ADDSDeployment
Install-ADDSDomainController -DomainName lucernpub.com -Credential
(Get-Credential) -installDNS:$true -NoGlobalCatalog:$false -DatabasePath "E:\NTDS" -Logpath "E:\Logs" -SysvolPath "E:\SYSVOL" -Sitename RemoteLocation
This will add a domain controller to the lucernpub.com Active Directory domain, using credentials you will be prompted for securely. The domain controller will be installed with a DNS Server and configured as a global catalog server. All the Active Directory-related files are stored in corresponding folders on the E:\ drive, and when successful, the Windows Server installation you intend as domain controller will be rebooted automatically.
Replace the values in the preceding sample file with the values of your choice.