Powershell Active Directory - 将我的 get-aduser 搜索限制到特定 OU [和子 OU]

标签 powershell active-directory

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

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

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

最佳答案

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

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

请注意,Get-ADUser 默认使用

 -SearchScope Subtree

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

关于Powershell Active Directory - 将我的 get-aduser 搜索限制到特定 OU [和子 OU],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16369994/

相关文章:

powershell - 删除Azure VM时如何从存储blob中删除 "bootdiagnostics"容器?

powershell - PowerShell 'less'工具

xml - 在 Inno Setup 中删除 XML 元素的内容

c# - 在 PowerShell 中拆分、选择、加入

c# - 在 Active Directory 中的计算机上获取上次登录时间

c# - 使用 C# 在 Active Directory 中移动对象

powershell - 从文件名中间删除数字

powershell - nltest 输出对于与 new-object 一起使用无效吗?

asp.net - 从asp.net获取AD用户objectGuid的身份验证

java - 使用 NTLM 安全协议(protocol)连接到 LDAP (Active Directory)