如何將網域控制器新增至現有網域(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 Server 加入 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 Domain Services (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/