Module to test whether the given username(s) are members of the given group, optimized for speed in large AD environments.
Leverages the tokenGroups property of AD user accounts to avoid messy and expensive recursive operations to identify and flatten group memberships.
Must be run as your SU account (i.e. account that has access to secured AD properties), otherwise the data returned will be inaccurate.
- Download
Test-ADUserIsMemberOfGroup.psm1to the appropriate subdirectory of your PowerShell modules directory. - Run it using the examples and documentation provided below.
Test-ADUserIsMemberOfGroup -UserName @("jdoe1","jdoe2") -GroupName "group1"Required string array.
The names of the AD users for which to test membership in -Group.
Required string.
The name of the group to test for membership of -UserName.
- See also: https://github.com/engrit-illinois/Get-AdUserGroupMembershipTree
- By mseng3. See my other projects here: https://github.com/mmseng/code-compendium.