The company has an AD structure that I need to search for the groupnames where the user is member. I do know it should be in the "memberof" attribute for the users, let's just say that is not always correct.
I tried the below code to find the username (or objectname) within the "members" attribute for all of the groups within an OU and then bring back the name of the group. Unfortunately I think I am missing something. Reverse search (IE: listing the members of a group) is working, but in my case I do not know the name of the groups. Also I need all of the groups, not just a single.
uname ="*anyoldusername*" $Searcher = [ADSISearcher]"(member=$uname)" $Searcher.SearchRoot = [ADSI] "LDAP://mydomainsearchroot" $Searcher.PageSize = 10000 $result = $Searcher.FindAll().Properties.cn echo $result
MemberOfis wrong, you have more serious problems.