[英]Powershell Active Directory - Limiting my get-aduser search to a specific OU [and sub OUs]
Just wrote a script that disables an account, moves it to a disabled OU and changes the description on the user object, but I want to make it more efficient. 刚刚编写了一个脚本来禁用帐户,将其移动到禁用的OU并更改用户对象上的描述,但是我想使其更加有效。
My work AD structure has all users under Root - accounts OU, and the 50 or so department OUs under that accounts OU. 我的工作广告结构在“根”帐户OU下有所有用户,在该帐户OU下有50个左右的部门OU。
How can I START my search at the accounts OU and have it check every sub OU in accounts? 如何在帐户OU中开始搜索并检查帐户中的每个子OU?
If I understand you correctly, you need to use -SearchBase: 如果我对您的理解正确,则需要使用-SearchBase:
Get-ADUser -SearchBase "OU=Accounts,OU=RootOU,DC=ChildDomain,DC=RootDomain,DC=com" -Filter *
Note that Get-ADUser defaults to using 请注意,Get-ADUser默认使用
-SearchScope Subtree
so you don't need to specify it. 因此您无需指定它。 It's this that gives you all sub-OUs (and sub-sub-OUs, etc.). 正是这样为您提供了所有子OU(以及子子OU等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.