I am trying to retrieve a list of all users that are NOT a member of any of specified groups (11 total).
I am able to get a list of users that are a member of each group, but am having trouble getting users that do not belong to any of the specified groups.
The desired output should be a list of DisplayName, Office, memberof
Any assistance would be much appreciated, below is the code I have so far…
The attribute MemberOf contains an array of the distinguished names of the groups an AD user is member of. So you can compare this array agains a list of distinguished names of groups you specified.
And BTW: When you post code you should format it as code please
… “simplify” ??? Why is this simpler? You query the AD once for the desired groups and once for ALL AD users … just like me. Then you compare the users against the members of the groups. … just another way around I’d say.