将本地Active Directory用户同步至Microsoft Entra ID(一)初始化安装Active Directory
1) 以管理员身份打开 Windows PowerShell ISE,执行“Set-ExecutionPolicy remotesigned“命令来将powershell策略设置为可远程执行。
2)在本地Active Directory环境中的Windows PowerShell ISE中输入下定义好的Powershell的脚本来初始化Windows网络配置,其中各项参数配置如表1-1所示
#Declare variables
$ipaddress = "172.16.67.171"
$ipprefix = "20"
$ipgw = "172.16.79.253"
$ipdns = "100.100.2.136"
$ipdns2 = "100.100.2.138"
$ipif = (Get-NetAdapter).ifIndex
$featureLogPath = "c:\poshlog\featurelog.txt"
$newname = "Dang"
$addsTools = "RSAT-AD-Tools"
表1-1 网络配置参数
3)在Windows PowerShell ISE中输入下定义好的Powershell的脚本来初始化Windows Server AD 必备组件
#Set a static IP address
New-NetIPAddress -IPAddress $ipaddress -PrefixLength $ipprefix -InterfaceIndex $ipif -DefaultGateway $ipgw
# Set the DNS servers
Set-DnsClientServerAddress -InterfaceIndex $ipif -ServerAddresses ($ipdns, $ipdns2)
#Rename the computer
Rename-Computer -NewName $newname -force
#Install features
New-Item $featureLogPath -ItemType file -Force
Add-WindowsFeature $addsTools
Get-WindowsFeature | Where installed >>$featureLogPath
#Restart the computer
Restart-Computer
4)随后使用如下脚本通过异步作业来安装所需的服务器角色和功能,然后创建一个新的Active Directory森林。
Declare variables
$DatabasePath = "c:\windows\NTDS"
$DomainMode = "WinThreshold"
$DomainName = "dang.gxsec.net.cn"
$DomainNetBIOSName = "dangad"
$ForestMode = "WinThreshold"
$LogPath = "c:\windows\NTDS"
$SysVolPath = "c:\windows\SYSVOL"
$featureLogPath = "c:\poshlog\featurelog.txt"
$Password = "DangJason123"
$SecureString = ConvertTo-SecureString $Password -AsPlainText -Force
#Install Active Directory Domain Services, DNS, and Group Policy Management Console
start-job -Name addFeature -ScriptBlock {
Add-WindowsFeature -Name "ad-domain-services" -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name "dns" -IncludeAllSubFeature -IncludeManagementTools
Add-WindowsFeature -Name "gpmc" -IncludeAllSubFeature -IncludeManagementTools }
Wait-Job -Name addFeature
Get-WindowsFeature | Where installed >>$featureLogPath
#Create a new Windows Server AD forest
Install-ADDSForest -CreateDnsDelegation:$false -DatabasePath $DatabasePath -DomainMode $DomainMode -DomainName $DomainName -SafeModeAdministratorPassword $SecureString -DomainNetbiosName $DomainNetBIOSName -ForestMode $ForestMode -InstallDns:$true -LogPath $LogPath -NoRebootOnCompletion:$false -SysvolPath $SysVolPath -Force:$true
PowerShell脚本中使用的变量及其描述,如下表所示:
表1-2 配置参数详解
5)安装完毕后,服务器会自动进行重启,当重启完毕后,打开“服务器管理器—本地服务器—Active Directory用户和计算机”,如下图所示,证明我们已经成功安装好了Active Directory。
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 慧眸
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果