使用 PowerShell 管理 Active Directory
1. PowerShell 与 Active Directory 概述
PowerShell 2.0 拥有超过 90 个专门用于 Active Directory (AD) 的 cmdlet。在 PowerShell 1.0 中,操作 AD 对象并不容易,因为需要深入了解轻量级目录访问协议 (LDAP)。而在 PowerShell 2.0 中,虽然仍需了解 LDAP,但无需像在 1.0 版本中那样深入。
借助 PowerShell 2.0 及其内置的 AD cmdlet,能更轻松地处理 AD 中的用户、组、组织单位 (OU) 等对象。这些 cmdlet 位于随 Active Directory 服务器角色提供的 AD 模块中。此外,Windows Server 2008 R2 为 AD 提供了一些新服务,如托管服务账户和 AD 回收站等强大功能。
2. 操作 Active Directory
PowerShell 可让你在 AD 环境中自动化处理用户和组。在 Windows Server 2008 中,使用 PowerShell 管理对象较为繁琐,而 Windows Server 2008 R2 进行了多项改进,新创建的 PowerShell cmdlet 和 AD 回收站使在 PowerShell 层面操作 AD 更加便捷。
2.1 加载 AD PowerShell 模块
在使用新的 cmdlet 之前,需要加载 AD PowerShell 模块。安装 Active Directory 域服务后,Windows Server 2008 R2 服