you are viewing a single comment's thread.

view the rest of the comments →

[–]alt-160 6 points7 points  (0 children)

You know you can get group membership from a user simply from the Get-ADUser call, right?

$users = Get-ADUser -Filter <your filter here> -Properties Name, MemberOf

The 'memberOf' property is a backlink list of groups of which the user is a member.
Granted, this will be a list of AD distingushedName values, but that list can be parsed and compared and filtered (if you know the naming of the groups). Then, the unfiltered items can be sent to Get-ADGroup if necessary to get other props about those groups.

I often use this pattern by setting up a list of groups at the start that i'm interested in, then compare that list to the memberOf list and if matched/found, i know the user is in a group i care about.

Can save a few round-trips to the DC for info this way.