如何使用 PowerShell 脚本移动 AD 中的对象

在 Active Directory (AD) 中,将用户、计算机和组等对象在容器之间移动,有助于维护正确的结构、委派和策略应用。以下是使用 Windows PowerShell 和基于 GUI 的 AD management tool ADManager Plus 在 AD 中将对象移动到不同容器的对比。

Windows PowerShell

使用 PowerShell 将 AD 对象移动到不同 OU 的步骤:

  • 确定要移动对象的域
  • 确定需要修改的 LDAP 属性。
  • 编写脚本。
  • 在 Windows PowerShell 中执行脚本。

Windows PowerShell 脚本示例

 已复制
Move-ADObject -Identity "OU=ManagedGroups,DC=ABCCompany,DC=Com" -TargetPath "OU=Managed,DC=ABCCompany,DC=Com"
点击复制整个脚本

ADManager Plus

将 AD 用户移动到另一个 OU:

  • 在 User Management -> Management 中选择 Move Users。
  • 选择目标 OU。
  • 从域和 OU 中选择所需用户,然后点击 Apply。

截图

» 开始 30 天免费试用

使用 Windows PowerShell 等原生工具移动 AD 用户时的限制如下:

  • 该脚本只能在具有 Active Directory Domain Services 角色的计算机上运行。
  • 添加额外筛选条件后,脚本会变得更长且复杂。
  • 解决这些脚本问题需要丰富的 AD 和脚本编写经验

ADManager Plus 可帮助您通过简单直观的 UI,仅使用 CSV 文件即可 批量移动用户到不同 OU

使用 CSV 文件批量将用户移动到不同 OU。

  获取 30 天免费试用。

开始您的 无脚本 AD 管理,报告和 自动化之旅 使用 ADManager Plus。

  •  
     
  • 提交即表示您同意根据 隐私政策 处理个人数据。

谢谢

您的下载将在 15 秒内自动开始。如未开始,点击此处手动下载。

相关 Powershell 操作指南:

Active Directory 管理和报告的一站式解决方案

电子邮件下载链接 Email the ADManager Plus download link