[英]Get all users that consist bunch of OU with the same names OU=NEEDOU. From a certain database
I'm wondering what I wrote is not correct.我想知道我写的不正确。 I need to get all users that consist of 10-20 OU with the same name OU=NEEDOU.我需要获取由 10-20 个 OU 组成的具有相同名称 OU=NEEDOU 的所有用户。 From a certain database.来自某个数据库。
Get-ADUser -Filter * -Properties DisplayName -SearchBase "OU=neededOU,OU=Mysearchbase,DC=randomname"| Get-ADUser -Filter * -Properties DisplayName -SearchBase "OU=neededOU,OU=Mysearchbase,DC=randomname"| where {$_.distinguishedname -like 'OU=NEEDOU*'}其中 {$_.distinguishedname -like 'OU=NEEDOU*'}
Get-ADUser -Filter * ... | Where-Object { $_.DistinguishedName -like "*,OU=NEEDOU,*" }
You forgot about starting *
in -like
operand.你忘了开始*
in -like
操作数。
Alternatively you can first search all needed OUs and then get users from them或者,您可以先搜索所有需要的 OU,然后从中获取用户
Get-ADOrganizationalUnit -Filter '(Name -eq "NEEDOU")' -SearchBase "..." -SearchScope Subtree |
ForEach-Object { Get-ADUser -SearchBase $_.DistinguishedName -Filter * -Properties @('...', '...') }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.