[英]Loop through multiple Active Directory Ou's in Powershell
How do you search multiple OU's in Active Directory. 如何在Active Directory中搜索多个OU。 Say if there are 4 OU's for different users, and need to search only 3 of the 4. Currently I am using the below to search one path, how would I expand that to search multiple OU's. 假设如果有4个OU用于不同的用户,并且只需要搜索4个中的3个。当前,我正在使用以下内容搜索一个路径,我将如何扩展该路径以搜索多个OU。
$OU='AD Path'
Get-ADUser -SearchBase $OU -Properties Lastlogondate -filter {lastlogondate -lt $DisableDays}
It looks like -searchbase takes <string>
, so you would need to loop through OUs. 看起来-searchbase需要<string>
,因此您需要遍历OU。
The following query would get users in each OU: 以下查询将获取每个OU中的用户:
$OU=@('cn=users,dc=xyz,dc=com','ou=companyusers,dc=xyz,dc=com')
$ou | foreach { get-aduser -searchbase $_ ...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.