PowerShell的活动目录 - 限制我的GET-ADUser便有搜索结果发送给特定的OU [和子OU中] [英] Powershell Active Directory - Limiting my get-aduser search to a specific OU [and sub OUs]

查看:398
本文介绍了PowerShell的活动目录 - 限制我的GET-ADUser便有搜索结果发送给特定的OU [和子OU中]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是写道,禁用一个帐号,它移动到已禁用的OU并改变用户对象的描述的脚本,但我想使它更有效率。

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.

我的工作AD结构具有根目录下的所有用户 - 帐户OU,以及50个左右部门OU下的帐户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的帐户?

How can I START my search at the accounts OU and have it check every sub OU in accounts?

推荐答案

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

If I understand you correctly, you need to use -SearchBase:

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

需要注意的是获取-ADUser便有默认使用

Note that Get-ADUser defaults to using

 -SearchScope Subtree

所以你不需要指定它。这是这足以给大家子OU(以及子子OU,等)。

so you don't need to specify it. It's this that gives you all sub-OUs (and sub-sub-OUs, etc.).

这篇关于PowerShell的活动目录 - 限制我的GET-ADUser便有搜索结果发送给特定的OU [和子OU中]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆