将计算机加入 Active Directory
2 简介
- Active Directory 是一种 Windows “目录服务” 由 Microsoft (微软)开发。在 Windows Server 2000 操作系统平台中加入的功能组件。为 Windows 平台提供统一管理,所有居于 Windows 平台的可用性服务,都严重依赖 Active Directory
- Active Directory 提供了跨平台服务,除了Windows 平台外,还提供 Linux、Unix 平台和 Mac 平台的服务。
- Azure 平台更是严重依赖 Active Directory 的服务
3 简介
- Active Directory (活动目录) 是 Microsoft (微软) Windows Server 家族产品中的核心功能组件。它提供了包括但不限于 Domain(域)、Single Sign On(单点登入)、uniform identity authentication(统一身份验证)、Organizational Unit(组织单位)、Computer(计算机)、User Group(用户组)和 User(用户)、资源、以及联系人等等的,管理。
运行 Active Directory 服务(AD DS)的服务器称为 Domain controller(域控制器) - Active Directory 同时还提供 Lightweight Directory Access Protocol 轻行目录访问协议(LDAP)
将计算机加入 Active Directory
配置 Server 的 基本设置
Configuring the basic setting of the Server server (配置 SQL 节点间的基本配置)
1 2 3 4 5 |
# 非必需 # 1. 找到本地网络适配器连接为 UP 状态的适配重命名为 LAN Get-NetAdapter | Where-Object {$_.Status -eq "Up"} | Rename-NetAdapter -NewName "LAN" |
Add the server to the Active directory (将服务器添加到活动目录中)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#获取主机名称 # hostname # $Rename = Read-Host "请输入加入活动目录前需要修改的计算机名称" # if ($Rename -notmatch ${host rules}) # { # Write-Warning "请输入正确的计算机名"; # break # } # $localuser = Read-Host "请输入具有加入 AD 权限的本地账户" # if ($Rename -notmatch ${localuser rules}) # { # Write-Warning "请输入正确的 AD 账户"; # break # } # $AD = Read-Host "请输入加入 AD 的域名称" # if ($Rename -notmatch ${AD rules}) # { # Write-Warning "请输入正确的域名"; # break # } # $ADuser = Read-Host "请输入加入 AD 的用户" # if ($Rename -notmatch ${ADuser rules}) # { # Write-Warning "请输入正确的域用户"; # break # } # #使用本地主机“localhost”格式加域,并指定加入域后新的计算机名, # Add-Computer -ComputerName "localhost" -LocalCredential "localhost\$localuser" -DomainName "$AD" -Credential "$AD\$ADuser" -NewName "$Rename" -Restart -Force # # 将生产账户加入必要的本地用户组 # net localgroup "administrators" "$AD\$ADuser" /add # net localgroup "IIS_IUSRS" "$AD\$ADuser" /add # net localgroup "Power Users" "$AD\$ADuser" /add # net localgroup "Remote Desktop Users" "$AD\$ADuser" /add # net localgroup "Remote Management Users" "$AD\$ADuser" /ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 定义 ############################################################################################################################# $Domain = "WEM" # 定义域名的名称 $TLDs = ".local" # 定义顶级域名 top-level domains $Province = "Sichuan" # 定义省份 $City = "ChnegDu" # 定义城市 $Password = "Admin@123" # 定义加入活动目录的密码 $NewComputerName = "Node1" # 定义加入 AD 后New Domain Computer Name $DomainUser = "$Domain$TLDs\Administrator" # 定义加入 AD 时需要验证的用户名 #$OUPath = OU=$Domain,DC=$Domain,DC=local" ############################################################################################################################## $DomainUserPassword = "$Password" | ConvertTo-SecureString -asPlainText -Force # 定义加入 AD 时需要验证的用户的密码 $UserPassword = New-Object System.Management.Automation.PSCredential($DomainUser,$DimainUserPassword) # 1. 找到本地网络适配器连接为 UP 状态的适配重命名为 LAN Get-NetAdapter | Where-Object {$_.Status -eq "Up"} | Rename-NetAdapter -NewName "LAN 01" # 加入 Active directory,并修改计算名称为新的 SQL1,然后重启计算机 Add-Computer -DomainName "$Domain$TLDs" -Credential $UserPassword -NewName "$NewComputerName" # 将 AD 上的角色任务,和管理员加入本机管理用户组 net localgroup "Remote Management Users" "$DomainUser" /add net localgroup "Remote Desktop Users" "$DomainUser" /add net localgroup "Administrators" "$DomainUser" /add net localgroup "Power Users" "$DomainUser" /add net localgroup "IIS_IUSRS" "$DomainUser" /add # 关闭防火墙网络 Domain,Private,Public 三个网络 Set-NetFirewallProfile -Name Domain,Private,Public -Enabled False # 重启计算机 Restart-Computer |