我目前有ADSI代码来获取用户所属的组:
$searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
$searcher.FindOne().Properties.memberof
$adgroups = $User -Replace '^cn=([^,]+).+$', '$1'但是,我希望能够选择一个组并看到它的成员。我现在有这个代码来获取他们的DN和路径。
$Group = [ADSI]"LDAP://cn=Test,cn=Test,dc=some,dc=domain,dc=net"
$Members = $Group.Member | ForEach-Object {[ADSI]"LDAP://$_"}如果可能的话,我想获取其他属性(名称等)。任何帮助都将不胜感激,因为我已经尝试了一段时间。
发布于 2017-07-27 22:09:23
您已经拥有了这两部分,第一部分是查找组中的用户,第二部分是使用搜索器获取用户的属性。只需使用distinguishedname作为[adsisearcher]过滤器。
$Group = [ADSI]"LDAP://cn=Test,cn=Test,dc=some,dc=domain,dc=net"
$Group.Member | ForEach-Object {
$Searcher = [adsisearcher]"(distinguishedname=$_)"
$searcher.FindOne().Properties
}https://stackoverflow.com/questions/45351476
复制相似问题