【问题标题】:Powershell Active Directory - Limiting my get-aduser search to a specific OU [and sub OUs]Powershell Active Directory - 将我的 get-aduser 搜索限制为特定的 OU [和子 OU]
【发布时间】:2013-04-28 12:16:17
【问题描述】:

刚刚编写了一个禁用帐户的脚本,将其移动到禁用的 OU 并更改用户对象的描述,但我想让它更高效。

我的工作 AD 结构具有 Root 下的所有用户 - 帐户 OU,以及该帐户 OU 下的 50 个左右的部门 OU。

如何在账户 OU 中开始搜索并让它检查账户中的每个子 OU?

【问题讨论】:

  • 贵公司是否使用 AD 中的部门字段?

标签: powershell active-directory


【解决方案1】:

如果我理解正确,你需要使用 -SearchBase:

Get-ADUser -SearchBase "OU=Accounts,OU=RootOU,DC=ChildDomain,DC=RootDomain,DC=com" -Filter *

注意 Get-ADUser 默认使用

 -SearchScope Subtree

所以你不需要指定它。正是它为您提供了所有子 OU(和子子 OU 等)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 2020-02-08
    • 2021-06-14
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多