如何将域控制器添加到现有域(PowerShell)

如何将一个新的域控制器(DC)添加到现有的Active Directory(AD)域中?在本文中,我将向您展示如何快速将新的DC添加到AD。

本文适用于:Windows Server 2025,Windows Server 2019,Windows Server 2022和Windows Server 2016

检查您域的域和林功能级别

将Windows Server 2025域控制器添加到现有域的唯一主要先决条件是域功能级别必须是运行Windows Server 2016。我可以使用PowerShell来确认域和林功能级别。

Get-ADForest | fl Name, ForestMode
Get-ADDomain | fl Name, DomainMode
Using PowerShell to confirm the forest and domain functional levels

安装Windows Server并重命名服务器

初始设置包括启动一个新的虚拟机和安装Windows Server。当安装完成时,我可以使用此PowerShell命令来重命名计算机。

Rename-Computer -NewName "WS25-DC5" -Restart

使用SConfig检查更新

重新启动后,我可以使用PowerShell中的’SConfig’程序检查更新并安装它们。(它们已经安装完毕,因此没有待处理的更新)

Using SConfig to check for and install Windows Updates

再次重新启动后,我们需要为服务器分配一个静态IP地址。以下是命令。

New-NetIPAddress –IPAddress 192.168.1.138 -DefaultGateway 192.168.1.254 -PrefixLength 24 -InterfaceIndex (Get-NetAdapter).InterfaceIndex

Set-DNSClientServerAddress –InterfaceIndex (Get-NetAdapter).InterfaceIndex –ServerAddresses 192.168.1.240,192.168.1.241

这将在我的实验网络上分配静态IP 192.168.1.38,并将默认网关设置为,并将我的前两个DC添加为DNS服务器。我们加入计算机到域时将需要这个。

All set to join to AD and promote to DC

加入Windows服务器到Active Directory域

接下来的步骤是将计算机加入到我的AD域 – reinders.local。让我们使用这个命令一步完成整个过程。

Add-Computer -DomainName "reinders.local" -Restart
Using PowerShell to join my server to my domain

安装AD DS服务器角色

重新启动后,我将使用我的域管理员帐户(mreinders)登录到服务器。我们准备好了 – 我们可以首先运行此命令来安装Active Directory域服务(ADDS) 角色。

Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementTools
Installing the AD Domain Services role with PowerShell

将服务器升级为域控制器

完成后,我们可以运行此命令将服务器升级为DC。

Install-ADDSDomainController -DomainName "reinders.local" -InstallDns -Credential (Get-Credential) -Confirm:$false

一个快速提示 – 我需要暂时将我的域管理员帐户添加到企业管理员组,以允许此更改。查看Petri.com上的使用PowerShell管理Active Directory组 将您的帐户添加到企业管理员组。

Windows is configuring the server to be a DC

完成后,Windows 提示我重新启动。

After that is complete, we need to reboot. Notice the AD schema version was updated…

再重新启动一次,一切都正常。我可以使用 PowerShell 确认我们有 5 个 DC。

Get-ADDomainController -Filter * | Select-Object Name, IPv4Address, OperatingSystem

感谢阅读我关于将 Windows Server 服务器添加为现有 AD 域中的新域控制器的帖子。

Source:
https://petri.com/add-domain-controller-to-existing-domain-powershell/